Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Time's always rewinding

This topic is 2767 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

Hi,

static DWORD dwLastTime = timeGetTime();
m_fElapsedTime = static_cast<float>((timeGetTime() - dwLastTime) * 0.01f);
dwLastTime = timeGetTime();






I am not clear why m_fElapsedTime always resets to a smaller value during the course of the simulation. Sometimes it gets to a few hundreds and comes back down to a few tens. This function is called when there is an OnIdle message.
m_fElapsedTime is of type "float". Is it a normal expected behaviour in any game?
I am not sure about this, just an assumption:
If the time flip-flops between many values, will or will not the animation jumble and become out-of-control?
Any thoughts?
Thanks
Jack

[Edited by - lucky6969b on December 23, 2010 4:27:08 AM]

Share this post


Link to post
Share on other sites
Advertisement
You shouldn't be using OnIdle to control animations. OnIdle gets called when there are no messages in the queue and can be expected to vary greatly. Your elapsed time variable is one-hundredth of the number of milliseconds since the last time OnIdle was called, which probably has nothing to do with your animations.

You should be using timeGetTime or QueryPerformanceCounter in your run loop, not OnIdle.

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!