CodeBase - Frame Rate Independant Code Done Simple.
Return to the CodeBase listing
Category: Core
Version: 1.0
Information
Uploaded: 6th Jun 2007 15:39
Modified: 30th Sep 2008 16:52
Author: Mage
Summary
Framerate independent code. An ultra simple method for making games run the same speed no matter what the frame rate is. Even if the framerate jumps around.
Full Description
Framerate independant code.<br /> <br /> FrameTimer() is put in your main loop (all loops with sync in it). This updates the timing.<br /> <br /> If you are moving objects at a certain pace say Move Object 1, 2.5 multiply the distance by FrameX#. It will compensate for the framerate not being 60. Infact multiply FrameX# with anything that is affected by a change in frame rate. IE: Move Object 1, 2.5 * FrameX#<br /> <br /> If you need the game to pause at all, perhaps for a menu. Run FrameTimer_Reset() right before returning to the gameplay. This will reset the timing.<br /> <br /> <br /> FrameX# is a ratio based on the current fps. If frame rate is 60 then FrameX# = 1. If Framerate is 120 then FrameX# = 0.5. If frame rate is 30 then FrameX# = 2.<br /> It will make sure everything is moving at a consistent speed.<br /> <br /> Framerate is calculated per frame, not using the built in method.<br /> <br />
Comments
No comments yet.