Answered step by step
Verified Expert Solution
Link Copied!

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, I'm 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
room_list =[]
# 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.", 1,2, None, None]
room_list.append(room)
room =["You are in a petite dining room. you can only go north.", None, None, 0, None]
room_list.append(room)
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, 4,0,1]
room_list.append(room)
room =["You are in a brand new kitchen. You see a brand new 30-inch 6.2 cu. ft. Front Control Induction Range with Total Convection in Smudge-Proof Stainless. You can go to the hallway in the west.", None, 3,1, None]
room_list.append(room)
room =["You're 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, 2]
room_list.append(room)
# Creating a variable called current room to keep track of where they are
current_room =0
# Printing room list variable
print(room_list)
print(room_list[current_room][0])
done = False
# Started game loop
while not done:
print("
") # Blank line
print(room_list[current_room][0]) # Room description printing
# Asking for input
direction = input("Where do you wanna go?").lower()
# Asking for input - side note # need's workss
if direction =='n' and room_list[current_room][1] is not None:
current_room = room_list[current_room][1]
elif direction =='e' and room_list[current_room][2] is not None:
current_room = room_list[current_room][2]
elif direction =='s' and room_list[current_room][3] is not None:
current_room = room_list[current_room][3]
elif direction =='w' and room_list[current_room][4] is not None:
current_room = room_list[current_room][4]
elif direction == 'quit':
done = True
print("Quitting the game.")
else:
print("You can't go that way.")

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

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions