I am making a game of zombies and I am trying to make them die when I hit them. I have tried different methods, but they never work.
I just need some concepts to base my code on.
What I thought was:
having : if the bullet hits the zombie, take 10 away from its health;
another if: if health < 0, make a bool variable "Dead" true;
My zombies are stored in a vector, so:
for (int i = 0 ; i < zombie.size() ; i++ )
if( zombie[ i ].Dead )
zombie.clear( zombie.begin() + i )
But this didn't work, I shot one and it died, but when I shot the 2nd one, all of the zombies on the screen died. How can I do this effectively?
P.S: I have tried simple deleting the object using delete zombies[ i ], but the program just stops responding