Quote Originally Posted by Traveler
Hi Damot,

There are a few odd things in your code. First thing I noticed is the initialisation of StartDemo. There's no need to use a timer for this. Dxdraw has an event called onInitialize. If you add the StartDemo call there, you can remove the timer alltogether.

Second, I see you're using the DXSpriteEngine to draw tiles. I recommend using DirectDrawSurface instead. For an example, have a look at the third tutorial on my website. (It also includes scrolling)

Now for the important part, the reason the movement is so jerky is because your using GetTickCount not correctly (as you already guessed). In your code, 'Moveamount' will never reach a stable point. At one clock cylce it may be 2.1, the next cycle 3.4 or perhaps even 4. Adding a threshold should do the trick.
Thanks for your reply.

I've just solved it actually. I was using GetTickCount to calculate how quick the last frame was, so I could calculate an amount to move (MoveAmount) to achieve the desired X pixels per second.

I should have been using QueryPerformanceFrequency() &
QueryPerformanceCounter() to get a move acurate reading.

It's now MUCH smoother. If anyone wants to see the difference, reply here and I'll put it up.


I'll have a look at your site, thanks.