Frame Timing

Started by
3 comments, last by Daivuk 19 years, 7 months ago
Yes I did search the forum and no I don't want some copy paste solution. It would be great though if some one could jsut very clearly and concicely detail the concept for Frame Timing. I understand I need to store the time then run a while loop to waste time based on the stored info but theres some stuff about frequency and the windows function being very inefficent. So could some 1 just explain what exacly the info is needed for and how its compared in the while loop to waste time. And how this won't slow up a slower computer. Srry if I sound like a nub i'm really not just having trouble w\ this, found several conflicting examples that have confused me.
==============================
A Developers Blog | Dark Rock Studios - My Site
Advertisement
Um I mean since right now everything is frame dependent, I want movement and pretty much everything to be frame rate independent, well my solution rather then timing everything else was just to limit the frames to 30fps. So I would but a time wasting loop before my render function. My question is how to get the info for this loop. I need 2 store the original system time when the timer starts then I gues every time this loop runs i need 2 query the time again and save the last query.

So if the delta of last query and the new query is less then 333.33 miliseconds then just run the loop again, so it should limit a computer to only get to the render loop 30 times every second. But the time query function has got to slow down slower computers.

But what was this bout the frequency?
==============================
A Developers Blog | Dark Rock Studios - My Site
you're going about it a bit backwards.

Instead of limiting the frame rate you work out how far the object should have moved in the time passed and update it as such.
aw ok. This is going to be a bit more complex then...
==============================
A Developers Blog | Dark Rock Studios - My Site
not so complex...
You just have to know the number of mili-sec that have passed since the last frame.
For you animation its now simple :
Imagine you have an object, and it move along the x axis 1000 unit per seconde.
We calculate our Elapsed value (The number of mili-sec that have passed since the last frame). If this value is 1000, then you have a frame rate of 1 :P. 1 seconde have passed since the last frame.
So you object is moving depending the value of the Elapsed :
Object.x += 1000 * Elapsed;
After 1sec it should move about 1000 unit ;)
For all your animation, you have to use this Elapsed value.
If the player have a frame rate of 10 and another guy of 100, the object will move at the same speed for the two PC ;)
Good luck

This topic is closed to new replies.

Advertisement