• Create Account

Posted 19 October 2012 - 08:34 AM

Yeah, I have used a similar procedure for collisions and deallocation before. Something like the following:

// at some point in code
projectile missile;
new enemy[num];

// check for enemy collisions
for (short i = 0; i < num; i++)
{
enemy[i].move();

if (enemy[i].collide(missile) == true)
delete [i] enemy;
}



Please note that this is highly abridged. My game's world is actually based around a character array, so I don't even have to pass the object, just a character value.

Thanks for all your help though; I understood when BeerNutts mentioned the increment step being messed up because of calling the destructor.

Posted 18 October 2012 - 08:20 PM

Yeah, I have used a similar procedure for collisions and deallocation before. Something like the following:

// at some point in code
projectile missile;
new enemy[num];

// check for enemy collisions
for (short i = 0; i < num; i++)
{
enemy.move();

if (enemy[i].collide(missile) == true)
delete [i] enemy;
}



Please note that this is highly abridged. My game's world is actually based around a character array, so I don't even have to pass the object, just a character value.

Thanks for all your help though; I understood when BeerNutts mentioned the increment step being messed up because of calling the destructor.

Posted 18 October 2012 - 07:50 PM

Yeah, I have used a similar procedure for collisions and deallocation before. Something like the following:

// at some point in code
projectile missile;
new enemy[num];

// check for enemy collisions
for (short i = 0; i < num; i++)
{
enemy.move();

if (enemy[i].collide(missile) == true)
delete [i] enemy;
}



Please note that this is highly abridged.

Thanks for all your help though; I understood when BeerNutts mentioned the increment step being messed up because of calling the destructor.

PARTNERS