Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help in coding, I ' m trying to create a basic mansion game where rooms connect and you can travel around the rooms.
I need help in coding, Im trying to create a basic mansion game where rooms connect and you can travel around the rooms. it will involve a list of rooms that can be navigated by going north, east, south, or west. Each room will be a list with the room description, and then what rooms are in each of the directions. My probelm is my rooms don't connect, also is a little confusing any tips on how to improve it I need the rooms to connect. Here is the code. # Creating the empty array
roomlist
# Creating rooms
room You are in a major modern living room. You see a leather couch, barely used with tiny hairs all over it You can go either north or south.", None, None
roomlist.appendroom
room You are in a petite dining room. you can only go north.", None, None, None
roomlist.appendroom
room You are in a modern hallway. There is a massive dog, that will eat you if you don't move fast. Quickly choose between the east or the west or the south.", None,
roomlist.appendroom
room You are in a brand new kitchen. You see a brand new inch cu ft Front Control Induction Range with Total Convection in SmudgeProof Stainless. You can go to the hallway in the west.", None, None
roomlist.appendroom
room Youre in the biggest master bedroom in the world. It looks like the bed is ready to be slept on There's a hallway to the east.", None, None, None,
roomlist.appendroom
# Creating a variable called current room to keep track of where they are
currentroom
# Printing room list variable
printroomlist
printroomlistcurrentroom
done False
# Started game loop
while not done:
print
# Blank line
printroomlistcurrentroom # Room description printing
# Asking for input
direction inputWhere do you wanna golower
# Asking for input side note # need's workss
if direction n and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction e and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction s and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction w and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction 'quit':
done True
printQuitting the game."
else:
printYou can't go that way."
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started