Search code examples
iosgame-physics2d-games

What equation do endless running games use to set the player's speed?


I'm making an endless running game (e.g. canabalt, temple run, Jetpack Joyride) and I'm trying to get the "feel" of it right. So far, I'm using the following equation to set the speed:

speed = (time+500)*(.05+(time/300))

Any tips for how to make the increase feel just right, other than trial and error?


Solution

  • Well, I did something similar in one of my games but I did not increase speed constantly, I increased it once every minute or once the player reaches a certain amount of points. Like so:

    - (void)setTravelTimeTo:(NSNumber*)targetTime
    {
        if (maxTravelTime > targetTime.floatValue)
        {
            maxTravelTime -= 0.1f;
            [self performSelector:@selector(setTravelTimeTo:) withObject:targetTime afterDelay:2];
        }
    }
    

    Where maxTravelTime is the time or in your case speed. Just modify it to suit your needs. The travel time in this case was the time a moving platform needed to get across the whole screen.

    Hope it helps.