我想在python上做一个游戏,我的问题是我不能让游戏在运行时读取输入。(连退出的退出键都没有)。 我找不到问题,我以为是缺少勾选方法,但我只是添加了它,它仍然不起作用。 感谢您的帮助。你知道吗
谢谢。你知道吗
代码如下: 立即编辑游戏循环
astronut=Player()
astronut.paintplayer()
while True:
screen.fill(WHITE)
for event in pygame.event.get():
if event.type == QUIT:
terminate()
if event.type == KEYDOWN:
if event.type == K_ESCAPE:
terminate()
if event.type == K_UP:
astronut.acceleration +=1
astronut.speed = astronut.speed + astronut.acceleration
astronut.posY= astronut.posY + astronut.speed
elif astronut.posY<(WINDOWHEIGHT-OVERTHELINE-playerHeight):
astronut.acceleration -=1
astronut.speed = astronut.speed + astronut.acceleration
astronut.posY= astronut.posY + astronut.speed
astronut.paintplayer()
pygame.display.update()
mainClock.tick(FPS)
我想你需要检查一下事件.key而不是事件类型地址:
相关问题 更多 >
编程相关推荐