News for hackers. Stuff that matters.
Re:Making Sprite-based Games with Canvas by Lerc on Tuesday March 19, 2013 @04:49PM (#5403543)
There is a pitfall with the approach of update loop using variable time steps. Depending on the game type this can matter quite a great deal. Essentially it is analogous to an iterated solution of the three body problem. 50 tiny steps produces a different result to 10 big steps.

There was a Google contraption editing game(a Google IO demo?) that suffered from this approach quite badly. It was a set-up-and-go game which should perform deterministically, but was influenced by variations in frame-rate.

The easiest approach to fixing this is simply quantised time.

    var now = Date.now();
    while(gameAge < now) {
       update();
       gameAge+=stepDuration;
    }
    render();
    //with usual caveats of resyncing if now-gameAge is too large
The much harder (but possibly ideal) approach is to not even have such a time step at all and move in variable increments calculated at the point of interaction between entities. An example of this would be a snooker simulation which moves in steps when the balls make contact. Balls slowing, rolling and curving become calculus problems. Produces a very nice result but your brain explodes.
Re:Making Sprite-based Games with Canvas by shardling on Wednesday March 20, 2013 @12:33PM (#5408315)
I know the Crafty engine uses this technique; I was surprised by how well it works in practice.