Ok.. that last piece of code helped. Thank you!
Still have a problem that i just can't seem to be able to solve on my own. Please take a look at this piece of code and help me out.
It's a code that detects, when an ant(sprite) has been hit by a bullet... and when it was hit, it puts a sprite of a dead body in that position. But in this game i present the movement of the main character by moving the background. So when the player moves, the backround coordinates change by changing the 'x' variable and 'y' variable (not visible in this function, since this is only a part of the much bigger code). So.. i need to move the ant bodies coordinates with +x and +y. The attempt fails: because, when i read the ant coordinates to new variables: 'anbodyX' and 'antbodyY', everytime a new ant is hit, the coordinates change for ALL the bodies at once.. so in the end, all the bodies are in the same place. How do I make them stay, in their primary position?
int bulletID = 500;
for (int i=0;i<=25;i++){
bulletID++;
int antID = 600;
int antbodyID = 700;
int static antbodyX = 0;
int static antbodyY = 0;
for (int j=0;j<=10;j++){
if (dbSpriteHit (antID, bulletID)){
dbSprite (antbodyID, dbSpriteX (antID), dbSpriteY (antID), (rand()%3)+7);
antbodyX = dbSpriteX (antID);
antbodyY = dbSpriteY (antID);
dbSizeSprite (antbodyID, 30, 34);
dbOffsetSprite (antbodyID, 15, 17);
dbRotateSprite (antbodyID, dbSpriteAngle (antID));
dbDeleteSprite (antID);
dbDeleteSprite (bulletID);
}
dbSprite (antbodyID, antbodyX+x, antbodyY+y, dbSpriteImage(antbodyID));
antID++;
antbodyID++;
}
}
if (bulletID >=520) bulletID = 500;
}
I just love the smell of code in the morning...