用户提示选择您自己的冒险游戏

2024-09-30 18:19:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经搜索了一个python选择你自己的冒险游戏,但我找到的最接近的是基于文本的游戏“Droids”,我使用了一些代码来创建下面的条件,根据用户的输入打印一本书的页面。我的问题是,如何创建一个条件,在每个页面显示给用户后进行提示,并返回正确的页面,然后显示一个新的提示来继续报道。在

#Defines the first page that is displayed
def page0():
    print "\n %s" % firstpage

def page3():
    print "\n %s" % thirdpage

def page10():
    print "\n %s" % tenthpage

#prints page 0
print page0()

#Choice 1 returns page 3 or 10 
ch1 = str(input("Type 3 or 10: "))


if ch1 in ['3']:
   print (thirdpage)

elif ch1 in ['10']:
    print (tenthpage)

Tags: or用户in文本游戏defpage页面