Jump to content
  • Advertisement
Sign in to follow this  
Wavesonics

Frame Timing

This topic is 5163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!