# skip jerky walk through (time based movements calculation)

## Recommended Posts

calidev234    100
I'm having a problem with the walk through movement of the a game loop. It’s a bit jerky or skippy. The movements are based off a time calculation. This problem does not happen on every computer (only a certain few, but on those few it’s consistent). I’ve seen many posts on the latency of the internal clock; but I haven’t seen a way to fix this. Below is a rough idea of the game loop. The app is a SDI app this is run in the app level class overriding the Run() function:
QueryPerformanceCounter((LARGE_INTEGER *) &llCurTime);

fFrameTime=(llCurTime-llLastTime)/(float) llTimerFreq;

llLastTime=llCurTime;

((CMainFrame *) m_pMainWnd)->m_wndView.Game_Run(fFrameTime);


Any ideas? Thank you very much.

##### Share on other sites
DrunkenHyena    805
Are these systems dual-processor or laptops?

##### Share on other sites
calidev234    100
Yes. A laptop. It was happening on a desktop (single processor) but after cleaning up the process and defragging it stopped happening. The one that remains is on a laptop though.

##### Share on other sites
Another thing to look out for is keeping track of time in seconds as a float. After a machine has been running for a day or two, the precision in the float can't represent the number of seconds and an accurate fraction of a second, and you'll see the time, and thus animations, updating at a much slower rate than the actual frame rate.

##### Share on other sites
Laptops often change the CPU frequency for low power consumption. QPC is reading the number of ticks the processor has run. Since the CPU is increasing and decreasing it's clockrate all the time on a laptop, you're getting inconsistant results.

A similar problem exists on dual-core systems where you have different tick counts on each of the two CPUs.

Try another timing option like timeGetTime(). I'm sure DH will have a few other options to throw your way too.

##### Share on other sites
jollyjeffers    1570
I don't see why this one is posted in "DirectX"... Moved to General Programming [smile]

Cheers,
Jack