dbSpriteCollision() returns a 1 if one sprite is overlapping another. Once they begin to overlap, they'll continue doing so for several frames. Hence each frame, your score increases. Although I see you're deleting the sprite, so that shouldn't happen. It could be a bug in the command. If you proceeded the command with a dbSpriteExist() call, that should solve it if that's what's going on - unless you're re-creating that sprite somewhere else?
if (((dbSpriteExist(201)) && (dbSpriteCollision(201,3)))
{
enumber=0;//do not care about this variable
dbDeleteSprite(201);
sc++;
//dbWait(1000);
}
Are you aware that both sc==1 and sc==3 both show sprite 12?
May I suggest a simpler score-showing function?
// Put '0' at the beginning of the sprite list, instead of at the end. So sprite 12 shows '0'. Sprite 13 shows '1'. 14 shows '2', etc.
int SpriteScore0 = 12;
int SpriteScoreCount = 6;
void Ennemy::score() // Note: There is one 'n' in the word "enemy".
{
int index, sprite;
sprite = SpriteScore0;
index = SpriteScoreCount;
while (index--)
{
dbHideSprite(sprite++);
}
dbShowSprite(SpriteScore0 + sc);
}
In the forum you can use the code tag so that source code will display properly. Just select your code, and then click the code button.
Judging what we see is the greatest blinder and self-limiter in the universe.
What we perceive is never reality. It is only a story we tell ourselves based on our current perspective, which has far more to do with our beliefs about ourselves than with anything else.