Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HW2 For this homework assignment, we will begin building a text-based game where you wander a maze until you encounter the exit. There will be

HW2 For this homework assignment, we will begin building a text-based game where you wander a maze until you encounter the exit. There will be monsters that you may encounter, at which time, you will have to fight them and win to proceed. Losing to a monster means losing the game and starting over. Players and monsters have a certain amount of health and are able to do a certain amount of damage per hit. Fight mechanics are pretty straightforward. You take turns attacking each other (monster and player) and the first person whos health reaches 0 loses. we want to think about building two functions. submit the matlab code that implements 1) Think about how you would create a function to do the following: a. It accepts at least 2 parameters: (msize, monsters) i. A size for the maze (maze should be square or NxN). ii. A value representing if you want to include monsters in the maze or not. b. It should return a complete maze with the following features: i. The maze is actually an NxN array of strings ii. 0 thats the number 0 as a string, represents an empty space iii. P represents the players current position (should be randomly assigned) iv. E represents the exit (should be randomly assigned) v. M represents monsters (should be randomly assigned, should be between 1 and 3 monsters on map) 2) Think about how you would create a function to do the following: a. It accepts at least 1 parameter (maze) i. A complete maze, like the function described in #1 b. It returns a complete, possibly modified maze c. The function should randomly move the player from their current x,y position to either 0, +-1 for x and y. i. If, as a result of the move, the player would move to the position marked E, then the player wins the game. Set all elements in the array to W and display a winning message ii. If, as a result of the move, the player would move to a position with a monster on it (M), the player should fight the monster. 1. For this week, the fight should just be rolling a random number (you can choose the range of numbers you pick from), and then asking the player to guess the number. a. If the player can guess correctly, then they beat the monster. The M should be replaced with P indicating that the player now occupies that space, and the original element that contained the P should be changed to 0, and you should notify the player of their new position. b. Otherwise, every element in the maze should be replaced with L, and you should display a message indicating that the game is lost. iii. If, as a result of the move, you simply land on an empty space, you should change the previous location to 0, change the new player position to P, and inform the player of their new coordinates.

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

What are the purposes of promotion ?

Answered: 1 week ago