[英]How do you do loops for a text based rpg on python?
我正在創建一個基於文本的 rpg,我需要弄清楚如何為它做循環,這樣我才能回到他們前進的主要故事板塊。 我需要將 Map 循環回選項部分。
story = input("What do you do? your choices -> Map, Travel, Exit")
if story == "Exit":
print("you left the game, goodbye" + " " + Name + "!")
import sys
sys.exit()
if story == "Map":
print("Your map shows an abandoned house, Lake, Lab, and abandon asylum.")
我不太清楚你的意思,也許是這樣的?
while True:
story = input("What do you do? your choices -> Map, Travel, Exit")
if story == "Exit":
print("you left the game, goodbye" + " " + Name + "!")
import sys
sys.exit()
if story == "Map":
print("Your map shows an abandoned house, Lake, Lab, and abandon asylum.")
不過,我個人會做一些改動:
import sys
while True:
story = input("What do you do? your choices are: Map, Travel, Exit").lower()
if story == "exit":
print("you left the game, goodbye {}!".format(Name))
sys.exit()
elif story == "map":
print("Your map shows an abandoned house, lake, lab, and abandoned asylum.")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.