Question
Answered step-by-step

Assignment 5B : Maze Game! 2D Arrays can be used to store and...

 Assignment 5B : Maze Game! 2D Arrays can be used to store and represent information
about video game levels or boards. You will use this knowledge to make an interactive game where players attempt to move through a maze. You will start by creating a pre-defined 2D array with the following values:
{"_","X","_","X","X"}
{"_","X","_","X","W"}
{"_","_","_","X","_"}
{"X","X","_","_","_"}
{"_","_","_","X","X"}
You will then set the player (represented by "O") at index 0, 0 of the array, the top-left
corner of the maze. You will use a loop to repeatedly prompt the user to enter a
direction ("Left", "Right", "Up", or "Down"). Based on these directions, you will try to
move the player.
• If the location is valid (represented by "_"), you will move the player there
• If the location is out of bounds (e.g. index 0, -1) or the command is invalid, you
will inform the player and prompt them to enter another direction
• If the location is a wall (represented by "X"), you will tell the user they hit a wall
and the game is over.
If the player did not lose, you will print out the current state of the map and ask them for
a new direction. You will keep doing this until they lose or they reach the end
(represented by the "W").
Sample Output #1:
[Maze Game]
O.X._.X.X.
_.X._.X.W.
_._._.X._.
X.X._._._.
_._._.X.X.
Which direction do you want to move? Up
You can't move there - it's out of bounds!
Which direction do you want to move? Down
_.X._.X.X.
O.X._.X.W.
_._._.X._.
X.X._._._.
_._._.X.X.
Which direction do you want to move? Down
_.X._.X.X.
_.X._.X.W.

O._._.X._.
X.X._._._.
_._._.X.X.
Which direction do you want to move? Down
You hit a wall - Game Over!
Sample Output #2:
[Maze Game]
O.X._.X.X.
_.X._.X.W.
_._._.X._.
X.X._._._.
_._._.X.X.
Which direction do you want to move? Eleventy
That's not a valid direction!
Which direction do you want to move? Down
_.X._.X.X.
O.X._.X.W.
_._._.X._.
X.X._._._.
_._._.X.X.
Which direction do you want to move? Down
_.X._.X.X.
_.X._.X.W.
O._._.X._.
X.X._._._.
_._._.X.X.
Which direction do you want to move? Right
_.X._.X.X.
_.X._.X.W.
_.O._.X._.
X.X._._._.
_._._.X.X.
Which direction do you want to move? Right
//Skipping ahead (This line is not part of the output)
_.X._.X.X.
_.X._.X.W.
_._._.X.O.
X.X._._._.
_._._.X.X.
Which direction do you want to move? Up
You win!

Answer & Explanation
Verified Solved by verified expert
Rated Helpful
<p>pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adip</p> Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet

Unlock full access to Course Hero

Explore over 16 million step-by-step answers from our library

Subscribe to view answer

dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum d

Step-by-step explanation

itur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet.a. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur la

gue

ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor

facilisis. Pellentesque

gue

ng elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laorefacinitriu

onec aliquet. Lorem ipsum dolor sit amet

gue

e vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque donec aliquet. Lonec facilisis. Pellentesque dapibus eff

a. Fusce dui lectus, congue vel laoreet ac, dictum

gue

molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam

m risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pul

gue

usce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet,

ipsum dolor sit amet, consectetur adipiscing

gue

at, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie c

dictum vitae odio. Donec alique

gue

iscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante,m riinia pulvinar tortor nec facilisis. Pellentesque dapibus eff

cing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus effic

gue

molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Do

rem ipsum dolor sit amet, consectetur adipisc

gue

et, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficit

ng elit. Nam lacinia pulvinar tortor nec facilisis. Pelle

gue

, consectetur adipiscing elit. Nam lacinia pulvinar tor

acinia pulvinar tortor nec facilisis. Pellentesque dapibus effic

gue

itur laoreet. Nam risus ante, dapibus a molestie

congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem i

gue

inia pulvinar tortor nec facilisis. Pellentesque

, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec f

gue

usce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum

or nec facilisis. Pellentesque dapibus efficitur lao

gue

sque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacin

trices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec f

gue

or nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel

molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar t

gue

amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesqtriur ltrirem ipsum dolor sit

ng elit. Nam lacinia pulvinar tortor nec

gue

ng elit. Nam lacinifacinitrim ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor

ce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur

gue

ctum vitae odio. Donec aliquet. Lorem ipsum

nec facilisis. Pellentesque dapibus

gue

amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus effic

ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque da

gue

iscing elit. Nam lacinia pulvinar tortor

28858009
28858012
28858011
28858010

gue

4 Attachments
maze_game_test1.PNG
PNG
maze_game_test2.PNG
PNG
maze_game_test3.PNG
PNG
maze_game_test4.PNG
PNG
Student reviews
100% (2 ratings)
Thorough explanation
Easy to follow
Clear formatting