Untitled
unknown
plain_text
5 months ago
2.6 kB
3
Indexable
import random def start_game(): print("Welcome to Granny's Horror Escape!") print("You find yourself in a dimly lit room.") print("What will you do?") print("1. Search for an exit") print("2. Hide under the bed") choice = input("> ") if choice == "1": search_exit() elif choice == "2": hide_under_bed() else: print("Invalid choice. Try again.") start_game() def search_exit(): print("You search for an exit and find two doors.") print("1. Open the left door") print("2. Open the right door") choice = input("> ") if choice == "1": left_door() elif choice == "2": right_door() else: print("Invalid choice. Try again.") search_exit() def hide_under_bed(): print("You hide under the bed, trying to be quiet.") if random.choice([True, False]): print("Granny walks in and doesn't notice you. You can try to escape now!") search_exit() else: print("Granny found you! Game over.") def left_door(): print("You enter a kitchen. There's a knife on the counter.") print("1. Take the knife") print("2. Leave it and continue searching") choice = input("> ") if choice == "1": print("You took the knife. Now you can defend yourself!") find_exit(True) elif choice == "2": find_exit(False) else: print("Invalid choice. Try again.") left_door() def right_door(): print("You enter a dark hallway. Granny is nearby!") print("1. Run back") print("2. Try to sneak past her") choice = input("> ") if choice == "1": print("You ran back to the room.") search_exit() elif choice == "2": if random.choice([True, False]): print("You sneaked past her! You can find an exit now.") find_exit(False) else: print("Granny caught you! Game over.") else: print("Invalid choice. Try again.") right_door() def find_exit(has_knife): print("You see an exit door.") if has_knife: print("1. Use the knife to break the door open") else: print("1. Try to open the door normally") choice = input("> ") if has_knife and choice == "1": print("You broke the door open and escaped! You win!") elif not has_knife and choice == "1": print("The door won't budge. You are trapped! Game over.") else: print("You escaped through the door safely! You win!") # Start the game start_game()
Editor is loading...
Leave a Comment