string = "Your NEW name is ALBY. You have 3 minutes to get to your shelter or you get RIPPED APART by gamma radiation and A MASSIVE FIREBALL. Do you RUN, SHELTER, or WAIT?"
for char in string:
print(char, end='')
time.sleep(.05)
print("")
time.sleep(5)
answer1 = input("What do you do?")
while True:
if answer1 == "RUN":
print("")
print ("You choose to RUN. Within minutes of running you see a massive
FIREBALL behind you, say your PRAYERS and DIE.")
print("")
time.sleep(5)
print("You Died! The creator of this game can't use 'While True'
statements and therefore you must restart.")
elif answer1 == "WAIT":
print("This is certainly not YOUR BEST IDEA. You WAIT for the bomb to drop
and DIE a hot death.")
print("")
time.sleep(5)
print("")
print("You Died! The creator of this game can't use 'While True' statements and therefore you must restart.")
elif answer1 == "SHELTER":
def slowprint(s):
for c in s + '\n':
sys.stdout.write(c)
sys.stdout.flush() # defeat buffering
time.sleep(random.random() * 0.1)
slowprint('Hello, world.')
上面是代码片段,我有打字机效果进行一些文字冒险。当我运行代码时,所有发生的事情都是我得到一个空白循环或该行的第一个字母。
[编辑:这不是冲洗问题的重复。我不想刷新我需要的慢速印刷来重新定义它。]