- This wiki is out of date, use the continuation of this wiki instead
Frame time
From FenixWiki
(Difference between revisions)
Revision as of 18:59, 27 December 2007 (edit) Sandman (Talk | contribs) m (→Definition) ← Previous diff |
Revision as of 00:09, 21 January 2008 (edit) (undo) Sandman (Talk | contribs) m (→Example) Next diff → |
||
Line 29: | Line 29: | ||
</pre> | </pre> | ||
- | This can be done with a timer too, as is displayed [[timer#Example|here]]. | + | This can be done with a timer too, as is displayed [[timer#Example|here]], along with an example on how to measure time using frame_time. |
{{Globals}} | {{Globals}} |
Revision as of 00:09, 21 January 2008
Definition
FLOAT frame_time
Frame_time is a global variable, holding the time passed the last frame. In other words: the difference in time between the start of the last frame and the current frame.
Doing a bit of physics, we see that:
- FPS = 1 / frame_time
Be advised that frame_time is in milliseconds accurate, so it can be 0 at times, so one might prevent such a case from happening:
- FPS = 1 / ( frame_time + (frame_time==0)*0.0001 );
This gives a sort of FPS which is accurate every frame.
Example
Let a process wait for a certain time by calling this function:
Function int wait(float seconds) Begin While( (seconds-=frame_time) > 0 ) frame; End return -seconds; End
This can be done with a timer too, as is displayed here, along with an example on how to measure time using frame_time.
Global variables | |
• Argc • Argv • Cdinfo • Dump_type • Fading • Fileinfo • Fps • Frame_time • Full_screen • Graph_mode • Mouse • Os_id • Restore_type • Scale_mode • Scroll • Sound_channels • Sound_freq • Sound_mode • Text_flags • Text_z • Timer • |