Created
July 29, 2021 17:09
-
-
Save panchishin/c33c7ddcac24c0a1410a919082aeb9f5 to your computer and use it in GitHub Desktop.
Very simple text adventure example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getChoice(choices): | |
message = "Pick one of : " + ", ".join(choices) + " > " | |
choice = "" | |
while choice not in choices: | |
choice = input(message) | |
print() | |
return choice | |
if __name__ == "__main__": | |
print() | |
print("You are in a room with 2 exists, north and south. You smell something horrible to the south and a warm light comes from the north. Which way do you go?") | |
decision = getChoice(['north','south']) | |
if (decision == 'north'): | |
print("The warm light turned out to be an incinerator. You died. Try again") | |
else : | |
print("You have entered the sewage pumping station. You see the toxic avenger here. Do you 'fight' or 'wave'?") | |
decision = getChoice(['fight','wave']) | |
if (decision == 'fight'): | |
print("Terrible choice, the toxic avenger never loses. You died. Try again") | |
else : | |
print("He is now your friend and shows you the exit. You win.") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment