When ever to run the following piece of code in my game it crashes. I have narrowed down the problem to being initiating mEnemies[i] = NULL and mSpaceship.mBullets[c] = NULL. Got no idea why. Please help
for(int i=0; i<mEnemies.size(); i++)
{
// cycle of bullets
for(int c=0; c<mSpaceship.mBullets.size(); c++)
{
if(mSpaceship.mBullets[c]->checkCollision( *mEnemies[i] ))
{
delete mEnemies[i];
mEnemies[i] = NULL;
delete mSpaceship.mBullets[c];
mSpaceship.mBullets[c] = NULL;
breakLoop = true;
}
if(breakLoop)
break;
}
if(breakLoop)
break;
}