Fixed time-step

In some cases, the code for time management that we've written doesn't really apply correctly. Let's say we only want to call certain methods at a fixed rate of 60 times per second. It could be a physics system that requires updating only a certain amount of times, or it can be useful if the game is grid-based. Whatever the case is, when an update rate is really important, a fixed time-step is your friend. Unlike the variable time-step, where the next update and draw happens as soon as the previous one is done, the fixed time-step approach will ensure that certain game logic is only happening at a provided rate. It's fairly simple to implement a fixed time-step. First, we must make sure that instead of overwriting the elapsed time ...

Get SFML Game Development By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.