Search code examples
iosobjective-csprite-kit2d-games

Speed up game after every 50 points


I am making a 2D reaction game with sprite-kit and I am having the same problem again. I already asked this question once and had good answers and everything worked finde but now I am stuck again.

Like the title says I want to speed up my game every 50 points, but it just speeds up when I get the right point number like 50, 100, 150.. The problem is that I have combo points and its always some points more. For example from 48 to 51 points, so it never speeds up. How can I speed up the game even its some points more ? I mean from 50 to 100 one speed up and from 100 to 150 and so on. Here is my code so far:

if (points % 10 == 0) {

    if (readyToSpeed) {

        speed++;
        NSLog(@"speed up");
        readyToSpeed = NO;
    }
}

Thanks for the help ! (code in objective-c please)

EDIT: Works perfectly using both answers combined.


Solution

  • Instead of incrementing your speed you could do it like so:

    speed = baseSpeed + (points / 50);
    

    Where baseSpeed is the speed at the start of the game.