Question: doMonsterAttack ( ) Open logic.cpp and locate the doMonsterAttack function. Make sure to read the block comment describing the function. Consider all possible and meaningfully

doMonsterAttack()
Open logic.cpp and locate the doMonsterAttack function. Make sure to read the block comment describing the function.
Consider all possible and meaningfully different map/game states and write code that implements the correct behavior for those states.
Correct behavior:
All monsters with a vertical or horizontal line of sight to the player move 1 tile closer to the player
Starting from the tile above the adventurers location and working upward, check each individual tile to see if there is a monster on the tile.
If there is a monster on a tile, move the monster one tile closer to the adventurer.
Continue to check until you have reached the top of the map or reach a pillar (monsters cant see through pillars)
Repeat the same logic with down, left, and right (in that order). Make sure all monsters that are supposed to move do so before you go to the next step.
Return true if a monster reaches the player, false otherwise.
The adventurer is killed if a monster moves onto their tile (check if the player position now contains a monster), return true (adventurer killed, game over) if so, otherwise return false (the monsters did not attack the adventurer, yet...).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!