【发布时间】:2020-07-16 09:01:27
【问题描述】:
我希望我的 python 程序在继续循环之前等待。但其他功能,循环usw。应该管用。如果我使用睡眠功能,整个程序就会进入睡眠状态。示例:
import pygame
def function():
print("You moved forward")
turtle.listen()
turtle.onkey(function, "f")
print("use f to move forward")
(Wait 5 seconds, so the player can try pressing f and sees what happens)
这是我原始代码的简单版本。我希望玩家尝试 WASD,因为角色会随着 WASD 移动。
如果我使用 time.sleep(),如果玩家按下 f,它将不起作用。
感谢您的任何回答:D
-> 顺便说一句,我的英语不好......
【问题讨论】:
-
我想做一个游戏教程。播放器使用 WASD 移动,因此应该有一个文本“按 WASD 移动”。然后玩家有几秒钟的时间按下 WASD 并四处移动。
-
input()怎么样。这将等到玩家按下 Enter 键 -
对不起,应该是评论,但我不能评论:(试试这个:stackoverflow.com/a/48111882/12658348
标签: python python-2.7 time pygame delay