Monster myMonsterList[10];
which i initialise to have x and y co-ordinates, later in the code, i need to "kill" the monsters, so my question is how do I ignore or delete part of the array.
this is where the monster moves randomly
for(int i=0; i < 10; i {
myMonsterList[i].monstermovement(i);
}
this is where i "kill" it
for(int i = 0; i < 10; i++)
{
if(x == myMonsterList[i].getX() && y == myMonsterList[i].getY()) {
cout << "Monster Killed!!!" << endl;
}
}
Thanks
(my tutor recommended a boolean of alive and dead, if so how would i initialise this when making the monsters)
I agree with your tutor. Another way would be to remove each dead monster from the array, in which case I would recommend using a vector. Using a bool to indicate alive or dead you would simply initialize it to true in the constructor-function, and then set it to false when the monster dies.