This site is no longer active and is available for archival purposes only. Registration and login is disabled.

time synchronized movement


time synchronized movement

Postby Cardinal » Sep 21, 2007 @ 7:03pm

Cardinal
pm Member
 
Posts: 53
Joined: Feb 6, 2006 @ 5:39am
Location: Ottawa, Ontario


Postby Dan East » Sep 22, 2007 @ 12:58am

I almost use milliseconds (1/1024th of a second to be exact).

So if velocity is in units per second, and delta time is an integer representing (almost) milliseconds duration of the frame:

pos += (velocity * delta_time) >> 10;

Now I don't care about the .024 loss of precision per second, so I use actual milliseconds (1/1000th) for delta_time (GetTickCount()). If that is a problem for you (maybe due to video / audio timing or something that must be properly synchronized) then you can adjust delta_time just once each frame to represent 1/1024 of a second.

Also, each frame you need to check to see if delta_time is zero. If your game runs really fast, or is on fast hardware, you can have issues with that. If delta_time is zero I just sleep for a couple milliseconds and start the frame over. That will make a massive difference with battery life if your game is not using 100% of the CPU.

Dan East
Last edited by Dan East on Sep 22, 2007 @ 1:50am, edited 1 time in total.
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby Cardinal » Sep 22, 2007 @ 1:46am

Hmm that seems to make more sense than the way I was doing it!

I'm going to have to experiment some more!
Cardinal
pm Member
 
Posts: 53
Joined: Feb 6, 2006 @ 5:39am
Location: Ottawa, Ontario


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron