# How do I know when a player has crossed a point threshold?

I’m needing help figuring out logic when adding a time bonus to my game.

I only want to reward the player with extra time if they level up.

Currently when the player’s score is less than 100 no bonus is given. If the player’s score reaches 200 I want to reward the player with some bonus time.

My issue is if the score is 190 and then jumps to 210, the 200 level mark is passed and the player isn't rewarded.

If I turn on the logic to say if the score is between 190 and 210, it could reward the player at the 190, 200, 210 mark or skip from 180 to 220, bypassing the reward altogether. I have tinkered with the idea of setting a bool BonusFlag, but the same issue arises, when I set the flag.

Can anyone help provide some logic on how to overcome this obstacle?

I'm assuming you will award bonus time very some amount of points (i.e. every 100 points, starting at 200), But this can be modified to handle any type of case.

Just use integer division to check if the value has been reached and update the last awarded value when reached. For example:

// this value should be global scope (class member)
int last = 1;   // last score awarded for (initialize so that 100-199 is skipped)

if ( score / 100 > last )  {
last++;      // only increase by ONE (prevents skipping values)