Итак, я создаю это на основе этого ресурса, связанного здесь: https://www.derekshidler.com/how-to-create-a-text-based-adventure-and-quiz-game-in-python/
РЕДАКТИРОВАТЬ: Вот ссылка GitHub на весь код: https://github.com/gabby-lucies/Quarter-1-Project/blob/master/intro.py
Яв настоящее время застрял, однако, в моем самом первом варианте, в любое время, чтобы выбрать любой из вариантов, перечисленных ниже, я получаю NameError, говоря, что мои параметры не определены. Кто-нибудь может дать мне какой-нибудь совет? Спасибо! Кроме того, извините, если это глупый вопрос.
#importing
import time
#How players could respond
answer_A = ["A", "a"]
answer_B = ["B", "b"]
answer_C = ["C", "c"]
yes = ["Y", "y", "yes"]
no = ["N", "n", "no"]
#Objects
fwomp = 0
bownarrow = 0
sword = 0
money = 0
#playerName = input("Enter Your Name: ") #gets the player's name, obviously
required = ("\nUse only A, B, or C.\n")
#Startup
def intro():
#print("There is no saving. Sorry!")
#print("Hello! Please enter your name.")
#print("Nice to meet you!")
print("Let's begin!")
print("You wake up in a forest. You can't remember anything. You look around and find")
print("a small creek. You hear sound nearby that sounds like some sort of woodland creature.")
print("You also see some smoke in the distance. What would you like to do ?")
time.sleep(2)
#Choice 1 Options
print("A. Follow the creek.")
print("B. Follow the sound of the woodland creature.")
print("C. Walk towards the smoke.")
choice = input(">>> ") #gets choice
time.sleep(1.5)
if choice in answer_A:
option_creek() #Gives player creek option
elif choice in answer_B:
option_animal() #Give Fwomp options
elif choice in answer_C:
option_smoke() #Gives smoke options
else:
print(required)
intro()
def option_creek():
print("You follow the creek for an hour, and you eventually come across the river.")
print("You followed the river for another hour, and you found a riverside village.")
print("You walk into the village, desperately looking for food and water.")
print("You come across a large pub. It doesn't look very busy.")
print("You also come across an elegant resturant. It must be very expensive.")
print("There is also family outside of their house eating freshly picked food from their garden.")
print("Where will you go?")
print("A. Pub B. Resturant C. Family")
time.sleep(2.5)
choice = input(">>> ")
if choice in answer_A:
option_pub()
if choice in answer_B:
option_resturant()
if choice in answer_C:
option_family()
else:
print(required)
option_creek()
def option_smoke():
print("You walk towards the smoke. Eventually you find the source of the smoke.")
print("The smoke is coming from a lost and very angry tribe.")
print("They also don't speak your language.")
print("When they spot you, and you have nothing to offer them in return, so they assume you are there to kill them.")
print("Anways, fifty of them shot you with arrows all at once.")
time.sleep(2)
print("Also, you're dead!")
time.sleep(2)
option_smoke()
def option_animal():
print("Seriously, you walked towards a strange animal sound just like that?")
print("Luckily, it is only a Fwomp. It doesn't kill you, but it does glare at you strangely.")
print("Fwomps are cute, so you want to pet it.")
print("You also want to take the Fwomp.")
print("You're also hungry and horrible so you also kind of want to eat the Fwomp.")
print("What will you do?")
print("A. Pet Fwomp B. Take Fwomp C. Eat Fwomp")
time.sleep(2.5)
choice = input(">>> ")
if choice in answer_A:
fwomp = 1
option_petfwomp()
elif choice in answer_B:
fwomp = 1
option_takefwomp()
elif choice in answer_C:
option_eatfwomp()
else:
print(required)
option_animal()