Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# PYTHON Beginner Adventure Game I'm working on. I need a little help trying to figure out how use the random module to randomly kill

# PYTHON Beginner Adventure Game I'm working on. I need a little help trying to figure out how use the random module to randomly kill a person at any point in the game. I'm not finished with the game but you can get an idea of how it's going with the code below. I need to do this with the random module.....using random.randint(1,100) which will generate a number. I'm just a little confused about where to put this in my code. Please let me know if you have any more questions about this.

import random

print() print("********************") print("********************") print("** ESCAPE ROOM **") print("********************") print("********************") print()

# Loop for the player keep playing game repeatedly until they enter something other than "yes" while True:

# Asking player if they want to play this game or not player_choice = input("Would you like to play the game called 'Escape Room' ? Enter (yeso): ").lower()

# Player decides to play game. They enter the "ROOM 1" (the lobby) from outside automatically by starting the game if player_choice == "yes": print() print("You and your two best friends agreed to try this new escape room everyone is talking about.") print("You have had fun doing these together before, and you've heard this one is especially hard.") print("You just entered the main entrance of the Escape Room's building and you are in the lobby.") print("You hear a loud mettalic clank sound and realize the door has locked behind you. You're thinking cool! Lets get started!") print() print("There are only two doors in this room. There are no windows, vents, and nothing on the walls.") print("You are wondering how the escape room is supposed to work with no clues or instructions.") print("Then all of a sudden a man's voice starts playing over a loud speaker. He continues on saying...") print() print("This is not a game, this is life and death. You must navigate through multiple rooms to the final room with the exit door. Do this if you wish to survive.") print("Every room has two doors to choose from besides the one you came in through(the door autolocks after entered).") print("One will lead to certain death, the other, you survive and move on to the next room.")

# Player chooses between door 1 or door 2 player_choice = input("What are you gonna do? Do you choose door 1 or door 2? (door1/door2): ").lower()

# This door 1 leads to death by fire in the room if player_choice == "door1": print("You enter door 1 into another room...A loud siren starts blasting! Boom! Fire shoots up from every inch of the floor roasting all of you. You die. Sorry! Game Over!")

# Player enters "ROOM 2" They are still alive. elif player_choice == "door2": player_choice = input("You enter door 2 into a room exactly the same as the first one. You have two more doors to choose from. What's it gonna be? (door1/door2): ").lower()

# Player enters into "ROOM 3" They are still alive. if player_choice == "door1": player_choice = input("You enter door 1 and you're still alive! Woohoo! What door are you gonna choose next, or do you want to pause and think? (door1/door2/think): ").lower() if player_choice == "door1"

elif player_choice == "think": print("You took too much time thinking! The room blew up in flames and everyone died! Sorry! Game Over!")

elif player_choice == "door2": print("You enter door 1 into another room...A loud siren starts blasting! Boom! Fire shoots up from every inch of the floor roasting all of you. You die. Sorry! Game Over!")

else: print("Alright then. Enjoy the rest of your day!") break

image text in transcribedimage text in transcribed

# Importing the random module for random death import random print() print("********************") print("********************") print("** ESCAPE ROOM **") print("********************") print("********************") print("Created by: Toby Hunt") print() # Don't forget to add the random generator. We'll use this and say that the friends took too long to decide on which door to enter, # and the entire room Lights up in flames roasting them all. random.randint(1,100) # Loop for the player keep playing game repeatedly until they enter something other than "yes" while True: # Asking player if they want to play this game or not player_choice input("Would you like to pla the game called 'Escape Room' ? Enter (yeso): ").lower() # Player decides to play game. They enter the "ROOM 1" (the Lobby) from outside automatically by starting the game if player_choice == "yes": print) print("You and your two best friends agreed to try this new escape room everyone is talking about.") print("You have had fun doing these together before, and you've heard this one is especially hard.") print("You just entered the main entrance of the Escape Room's building and you are in the lobby.") print("You hear a loud mettalic clank sound and realize the door has locked behind you. You're thinking cool! Lets get started!") print) print("There are only two doors in this room. There are no windows, vents, and nothing on the walls.") print("You are wondering how the escape room is supposed to work with no clues or instructions.") print("Then all of a sudden a man's voice starts playing over a loud speaker. He continues on saying...") print) print("This is not a game, this is life and death. You must navigate through multiple rooms to the final room with the exit door. Do this if you wish to survive.") print("Every room has two doors to choose from besides the one you came in through(the door autolocks after entered).") print("One will lead to certain death, the other, you survive and move on to the next room.") print("This is not a game, this is life and death. You must navigate through multiple rooms to the final room with the exit door. Do this if you wish to survive.") print("Every room has two doors to choose from besides the one you came in through(the door autolocks after entered).") print("One will lead to certain death, the other, you survive and move on to the next room.") # Player chooses between door 1 or door 2 player_choice = input("What are you gonna do? Do you choose door 1 or door 2? (door1/door2): ").lower() # This door 1 leads to death by fire in the room if player_choice == "door1": print("You enter door 1 into another room...A loud siren starts blasting! Boom! Fire shoots up from every inch of the floor roasting all of you. You die. Sorry! Game Over!") # Player enters "ROOM 2" They are still alive. elif player_choice == "door2": player_choice = input("You enter door 2 into a room exactly the same as the first one. You have two more doors to choose from. What's it gonna be? (door1/door2): ").lower() # Player enters into "ROOM 3" They are still alive. if player_choice == "door1": player_choice = input("You enter door 1 and you're still alive! Woohoo! What door are you gonna choose next, or do you want to pause and think? (door1/door2/think): ").lower() if player_choice == "door1" elif player_choice == "think": print("You took too much time thinking! The room blew up in flames and everyone died! Sorry! Game Over!") elif player_choice == "door2": print("You enter door 1 into another room...A loud siren starts blasting! Boom! Fire shoots up from every inch of the floor roasting all of you. You die. Sorry! Game Over!") else: print("Alright then. Enjoy the rest of your day!") break

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions