by InexorableTash » Feb 12, 2004 @ 5:31am
You don't have to use the CGapiApplication frame timer mechanism; I'd recommend either rolling your own, or instead of using frame ticks switching to absolute times (e.g. your high performance tick counts) to position items in the game world.
Think about this scenario: average frames take 20ms, per-frame time is set at 30ms (so 33.3 frames per second - that makes the other number round). So on average, the timer is going to sleep for 10ms per frame. Now you run into a frame that takes 45ms to render. Now, the timer would have to sleep for -5 seconds to catch up.
Most commercial games that I've seen either just "stutter" when there's an intense frame (e.g. the game slows down when there's lots of activity) or use absolute times (e.g. it takes 5 seconds for a ship to fly across the screen, whether that's 1 frame or 150 frames). In the latter case you probably want to cap the frame rate at some reasonable number so you're not consuming 100% CPU. The CGapiApplication timer seems to be an adequate implementation for both scenarios, but may not be for yours.