2024-07-07 03:00:26 发布
网友
我想做一个基于文本的选择你自己的冒险游戏
在这个游戏中,每个回合有三种选择:拾荒、休息和继续你的旅程。每次选择“继续您的旅程”时,区域变量向上移动一个。如果你在同一个地方翻了两遍,我希望它说“你什么也找不到”。但如果我必须写“如果面积==1,食堂==1: 打印“你找不到任何东西。”(食堂是你在第一个区域清理时得到的物品)如果我必须为每个选项都写上,我会非常沮丧。那么,有什么方法可以很容易地测试他们是否在该地区进行过清理,并说“你什么也找不到。”提前谢谢
如果你在寻找一些非常简单的东西,可以举个例子:
area = 0 inventory = [] area_scavenged = False while True: print 'Area: %s\nInventory: %s' % (area, str(inventory)) choice = raw_input("Choose an option: ") if choice == 'rest': pass elif choice == 'continue': area_scavenged = False area += 1 elif choice == 'scavenge': if not area_scavenged: # Append to inventory the item that corresponds to the area you're in inventory.append('whatever') area_scavenged = True else: print("You couldn't find anything") elif choice == 'end': break
如果你在寻找一些非常简单的东西,可以举个例子:
相关问题 更多 >
编程相关推荐