My asteroids are in a vector, so on impact, I tried deleting them, but every time I do, I get an out of range at memory location error.
to delete them I do
if(smallHit == true)
asteroidV.erase(asteroidV.begin()+smallHitNum);
smallHit is a bool that is set to true if the ship hits an asteroid and smallHitNum stores the location of the asteroid that was hit.
I also tried
if(smallHit == true)
{
for(int e=0;e<5;e++)
{
if(smallHitNumA[e] == e)
asteroidV.erase(asteroidV.begin()+smallHitNumA[e]);
}
}
There is more than 1 asteroid, so if one of them was hit, then i loop and check if smallHitNumA[e] == e.
smallHitNumA[] is an array of 5 with all the value initialized to -1. If an asteroid is hit, then the number of the one that hit it, get stored in the corresponding element in the array.