Pygame检测任何键关闭,而不仅仅是"S"键



当运行以下代码行时,用户应该按下"W"按钮开始冥想,按下"S"按钮停止冥想,但我发现,如果按下任何按钮,用户会根据DL[19]=4还是0开始或停止冥想。这是一个问题,因为我需要钥匙"a"one_answers"D"来浏览房间。关于如何解决这个问题,有什么建议吗?

if DL[19] == 0: # no activity
displaydata1 = font.render(" 'W' Key: meditate", True, (255,255,255))
screen.blit(displaydata1, (coordinates[0], coordinates[1] + 14))
if event.type == pygame.KEYDOWN:
if pygame.K_w:
DL[19] = 4 # set activity to meditating
elif DL[19] == 4: # meditating
displaydata1 = font.render(" 'S' Key: stop meditating", True, (255,255,255))
screen.blit(displaydata1, (coordinates[0], coordinates[1] + 14))
if event.type == pygame.KEYDOWN:
if pygame.K_s:
DL[19] = 0 # set to no activity
if DL[19] == 0: # no activity
displaydata1 = font.render(" 'W' Key: meditate", True, (255,255,255))
screen.blit(displaydata1, (coordinates[0], coordinates[1] + 14))
if event.type == pygame.KEYDOWN:
if event.type == pygame.K_w:
DL[19] = 4 # set activity to meditating
elif DL[19] == 4: # meditating
displaydata1 = font.render(" 'S' Key: stop meditating", True, (255,255,255))
screen.blit(displaydata1, (coordinates[0], coordinates[1] + 14))
if event.type == pygame.KEYDOWN:
if event.type == pygame.K_s:
DL[19] = 0 # set to no activity

你说CCD_ 1;w";被点击

相关内容

最新更新