输出反应是当我按下键盘6键后,显示屏上只是非常快的闪过blit的相关字符,然后恢复一无所有
这样的问题怎么解决
想要的结果是,按下6键,相应的字符停留在窗口上不消失,并且增加相应键位,按下时原先所有输入字符消失
源代码如下
import pygame
import sys
import random
import time
def kb():
if event.type==pygame.KEYDOWN:
jp=pygame.key.get_pressed()
if jp[pygame.K_6]:
print("www")
sc.blit(ft("6"),(0,0))
def ft(text):
font = pygame.font.SysFont('corble',40)
text = font.render(text,1,(0,0,0))
#render("文本",抗锯齿,rpg值)
rect = text.get_rect()
return text
pygame.init()
Fullscreen = True
bg = pygame.image.load('first.png')
#这是一张纯白的图片
bg = pygame.transform.scale(bg,(640,480))
screen=pygame.display.set_mode((640,480),Fullscreen,32)
pygame.display.set_caption("test")
sc = pygame.display.get_surface()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.display.quit()
exit()
sc.blit(bg,(0,0))
kb()
pygame.display.update()