Sign in to follow this  

Time's always rewinding

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

This topic is 2551 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this