if (points - lastCheckpoint >= 50)
{
// do something
lastCheckpoint = points - (points % 50);
}
Start with an int lastCheckpoint = 0;
during set-up, and this'll do the trick.
Caveat: If the points increase by 100 or more between checks, the // do something
will only be triggered once.
If you want it to happen for every 50 points regardless, you can change the increment statement to be lastCheckpoint += 50;
although this runs the risk of the points
running far ahead of lastCheckpoint
.
Edit: this will be more efficient:
if (points > nextCheckpoint)
{
// do something
nextCheckpoint = 50 + points - (points % 50);
}
Start with int nextCheckpoint = 50;
This way, the test that's performed (presumably) every iteration of the game loop doesn't include a subtraction.