Jump to content
  • Advertisement
Sign in to follow this  
dsage

Time based movement delta problem

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

I don't know if i'm getting a good figure for my delta. At 319fps i'm geting 0.004 and 0.003 as my delta. Then at 154fps i'm getting 0.006 and 0.007 as my delta. It doesn't sem very percise does it? Check out my code.
// FPS
if(SDL_GetTicks() - m_startTime >= 1000)
{
    m_fps = m_totalFrames;
    m_totalFrames = 0;
    m_startTime = SDL_GetTicks();
}
m_totalFrames++;

// Time based movement
m_oldTime = m_newTime;
m_newTime = SDL_GetTicks();
m_diffTime = m_newTime - m_oldTime;
m_delta = float(m_diffTime)/1000.0f; // <- o_0
Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
It looks fine to me. The time deltas may seem small, but they are measured in seconds and are running at several-hundred Hertz. You can easily verify that the values are okay:

319 * 0.004 = 1.276
319 * 0.003 = 0.957

154 * 0.006 = 0.924
154 * 0.007 = 1.078

So the total delta over a second is indeed roughly unit, as required.

Admiral

Share this post


Link to post
Share on other sites
Thanks for the reply. I see alot of page ripping. I'm going to try to average out the 3-5 delta totals and see if that helps. Thanks again.

Share this post


Link to post
Share on other sites
Hold on. What do you mean by 'page ripping'. This isn't a vertical-sync issue, is it?

I'm not sure what you're trying to achieve, but I get the feeling that averaging deltas together isn't the solution. Could you tell us what you're using the delta for and exactly what's wrong with the results?

Admiral

Share this post


Link to post
Share on other sites
Quote:
Original post by dsage
I don't know if i'm getting a good figure for my delta. At 319fps i'm geting 0.004 and 0.003 as my delta. Then at 154fps i'm getting 0.006 and 0.007 as my delta. It doesn't sem very percise does it?

Since SDL_GetTicks returns the number of milliseconds as an integer, it can't get any more precise than that.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!