Im creating a basic game using SDL/C++. I need a way to implement 2 hit detection. When just trying one hit it works fine. Here is what i have for the two hit detection:
int maxHit = 2;
int hitCount = 0;
// Detect collisions
for(auto p : projectiles) {
for(auto a : aliens) {
if(p->CollidesWith(a) && hitCount == maxHit)
{
p->HandleCollision();
a->HandleCollision();
}
if(p->CollidesWith(a) && hitCount != maxHit) {
++hitCount;
}
}
}
For some reason it works on a select few of the enemies on the screen and doesn't for others.
EDITED TO MAKE IT CLEARER