Hello everyone
I am having a strange issue with using the command dbSpriteCollision. For some reason, my game crashes everytime I use it and I'm not quite sure why. I have tried using several different image combinations so I don't think it is a weird issue with the images. Whenever it crashes, it tell me that there was an access violation. The same thing happens when I try using dbSpriteHit as well. Does anybody know why this is happening?
Example of my code, to show how I am using it:
void CWorld::collisionDetection() {
// Test to see if lasers have collided into anything
std::list<CLaser>::iterator iLaser = lLaser.begin();
while (iLaser != lLaser.end()) {
// Grab some values
int id = iLaser->getID();
// Test to see if laser needs to be deleted
if (dbSpriteCollision(id,17) == 1) {
UniqueIDManager.Push(id);
dbDeleteSprite(id);
iLaser = lLaser.erase(iLaser);
}
else
++iLaser;
}
}
Things I have tried:
- Using different images
- Using the command in different places in my code
- Setting a variable to the value and then using that in the if statement
Regardless of how I use it, dbSpriteCollision always crashes the game.