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 ie
function pointers when creating monsters. The game template
provides one attack behavior, but you are free to define more.
param game The game
void monsterActionGame 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
create optsnumMonsters number of monsters.
allocate memory for each monster in monsters array of the game
object ie
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.
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 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 createMonstersGame game
void game;
brief Determine whether the monsters move towards or away from the
player character.
param game The game
void checkIntentGame game
forunsigned int i ; i gamenumMonsters; i
Creature m &gamemonstersi;
ifmhp
mmove moveAway;
else
mmove moveTowards;
ifmhp mmaxhp
mhp mhp ; heals a bit every turn
this code is a continuation of the one in the picture. Basic C
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
