Sign in to follow this  
dsage

Time based movement delta problem

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
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
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

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