【发布时间】:2019-04-01 02:26:54
【问题描述】:
我正在创建一个基于文本的游戏,为了加快过去的对话,我希望用户能够点击“空格”并跳过它。
import time
import sys
text_speed = .05
def slow_type(line, speed): #You input the dialogue and speed(smaller = faster)
for l in line:
sys.stdout.write(l)
sys.stdout.flush()
time.sleep(speed)
time.sleep(.5)
if <'Space'> pressed:
text_speed = 0
NL1 = "Huh, I see you finally came. "
slow_type(NL1, text_speed)
【问题讨论】:
标签: python python-3.x keyboard keypress