craftyjs/Crafty — pull request #528 by starwed (2013-08-16 21:04:22+00:00)
Title: Customizable game loop

This patch reworks the game loop to allow control over its behavior. It can now be set to three modes, which control what dt is passed to each frame, as well as how often frames are called.

* "fixed", which is the existing behavior. Each frame processes the same amount of time, and as many frames as necessary are processed to reach the target rate.
* "variable", which processes a single frame per render. This frame is handed the total time since the last frame, up to some maximum value.
* "semifixed", which takes the total time since the last step, and splits it evenly between as many frames are necessary to avoid exceeding some maximum timestep.

It also cleans up how the game loop and Crafty.timer are actually implemented, moving a bunch of internal variables into the scope of Crafty.timer.