Question: * A . Function pointers attack and move in Creature * structure determine the action to be taken. You are required * to call these

* A. Function pointers attack and move in Creature
* structure determine the action to be taken. You are required
* to call these function pointers to invoke either of
* monster actions.
*
* If either of the function pointers is NULL, the respective
* action is ignored.
*
* B. You should specify valid attack and movement behaviors (i.e.,
* function pointers) when creating monsters. The game template
* provides one attack behavior, but you are free to define more.
*
*
*\param game The game
*/
void monsterAction(Game* game){
(void) game;
// TODO: implement this function
}
/**\brief Create opts.numMonsters monsters and position them on valid positions
* in the the game map. The moster data (hitpoints, name, map sign)
* should be set appropriately.
*
*\details The function should
*
*1. create ``opts.numMonsters`` number of monsters.
*
*2. allocate memory for each monster in ``monsters`` array of the ``game``
* object (i.e.).
*
*3. place them on random free positions on the map that are
*
* a. not wall tiles, and
* b. not occupied by other monsters, and
* v. inside the map area.
*
* hint:
* You can use isBlocked function to check if a monster can be
* placed at a random position.
*
*4. initializes other monster details, such as name, the map sign shown
* on the user interface, hitpoints, and so on.
*
* a. Each monster must have more than ``0`` hit points, and initial
* hit points should be set to the maximum HP.
*
* b. The monster name must be properly initialized.
*
* c. The monster's map sign must be an alphabetic character.
*
* d. The other fields can be initialized freely.
*
*\param game The game
*/
void createMonsters(Game* game){
(void) game;
}
/**
*\brief Determine whether the monsters move towards or away from the
* player character.
*
*\param game The game
*/
void checkIntent(Game* game){
for(unsigned int i =0; i game->numMonsters; i++){
Creature* m = &game->monsters[i];
if(m->hp =2){
m->move = moveAway;
} else {
m->move = moveTowards;
}
if(m->hp m->maxhp)
m->hp = m->hp +0.1; // heals a bit every turn
}
} this code is a continuation of the one in the picture. Basic C
* A . Function pointers attack and move in

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 Accounting Questions!