Page 1 of 1

timedelta

PostPosted: May 27, 2006 @ 4:55pm
by Petre
helo felow developers.

i am doing some testings with edge and i was woundering how i could use device independent timing in a game for animations, moving, input, etc.

i noticed the timedelta variable in the onnextframe loop, what is the best way to use it?

tank you!

petre

PostPosted: May 29, 2006 @ 8:37am
by edge
When using the timedelta parameter it's a good idea to measure animations in "units" rather than pixels (because the timedelta variable is usually bigger than the amount of pixels to move). It's not a good idea to divide the timedelta parameter, because the amount of movement may be 0 if the timedelta parameter contains a low value (this will be the case if the game runs at a high fps).

For example, when using sprites, update the x-position of the sprite using timedelta (sprite[0]->x += timedelta). When drawing, convert the "unit position" back to the position in pixels and draw it onscreen.

A good example of using timedelta is shown in the Blastar sample and tutorial on our website: http://www.edgelib.com

PostPosted: Jun 4, 2006 @ 5:56pm
by Petre

PostPosted: Jun 6, 2006 @ 8:19am
by edge