PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

timedelta

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
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
helo.
thank you for your explaination. i have another question: howe to use the ffwdkey en slomokey features?

tank you!

petre
If you're using timedelta for all your animations, you can assign keys to the ffwdkey and slomokey members of the Edge configuration. Timedelta will increase/decrease if these buttons are held. The result is that the game will run slower or faster which can be useful for testing and debugging.