# Time based movement delta problem

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

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

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

##### Share on other sites
Quote:
 Original post by dsageI 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.

1. 1
2. 2
Rutin
20
3. 3
khawk
17
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633759
• Total Posts
3013720
×