I created a collision detection game in XNA but I have a problem with the scoring. As online tutorials says, I initialised it
score = 0;
This is in the update section to check if the person hit the object
// Check collision with person
if (personRectangle.Intersects(numberRectangle))
personHit = true;
Then in the draw section..
if (personHit)
{
score = +score + 1;
spriteBatch.Draw(greenBackground, mainFrame, Color.White);
}
else if (personHit2)
{
score = +score - 1;
//device.Clear(Color.Red);
spriteBatch.Draw(redBackground, mainFrame, Color.White);
}
But when the person hits the objects that fall, the score goes up until that object is on the person image. I don't know if I am clear. The score doesn't go up by one per hit, it goes up until that object stops touching the person..
I was wondering how can I fix this so the score goes up by 1 only?