clintbellanger/flare-engine — pull request #1090 by dorkster (2014-06-11 19:58:01+00:00)
Title: Lock the engine at 60fps instead of 30fps

These changes allow us to change MAX_FRAMES_PER_SECOND freely, all while maintaining game behavior. All the places where we were using "ticks", we now use millisecond timing.

The big changes are with animations. Instead of setting the duration of a single frame in ticks, we set the duration of the entire animation in milliseconds. For example, a 4 frame animation that had duration of 3 ticks per frame (at 30fps) now has a duration of 400ms. Given a millisecond duration, we can calculate how many ticks the animation will actually be, and then space the frames accordingly across those ticks.

Animation frames are evenly spaced if the amount of frames and cleanly divide into the duration (in ticks). This is the case for all of the current flare-game data. However, if we can't evenly space frames, we fall back to the Bresenham algorithm. It didn't seem like it would work on paper, but in practice, I found the results from that algorithm to be plenty acceptable. The only place problems would be noticeable would be when using a very slow animation with very few frames. If we can come up with a better solution, I'm all for it. But we can roll with Bresenham for now.