Delta Time and Animation

BlitzMax Forums/BlitzMax Beginners Area/Delta Time and Animation

Ant(Posted 2006) [#1]
Ok, I've just been reading through all the posts on delta timing and my brain is no medium-well done, so excuse me if this is a daft question. Generally speaking, you have to apply delta time to everything that moves over time - does this then also apply to animation and advancing frames?

Going to dunk my head in a cold bucket of water.
cheers


jhague(Posted 2006) [#2]
Yes, if you're trying to handle variable framerates. In general, you shouldn't be stepping through frames manually. If you keep track of the time an animation started, then you can compute the proper frame based on that and the current time.


TomToad(Posted 2006) [#3]
What I usually do is I calculate the number of milliseconds between frames, then I can find out what frame I need to display. For instance, if I wanted to cycle an animation at 15 FPS then the number of milliseconds would be 1000/15. That would be 66.66666 mpf(milliseconds per frame). I would round it up to 67 mpf. Then I'd need to store the time the animation started. From there, just find out how much time has passed, devide by mpf, and Mod by the number of frames.
Const MPF = 67
Const NumFrames = 8

Local Frame:int

Local AnimStart:Int = Millisecs()
Local TimePassed:Int
...Some code goes here

TimePassed:Int = Millisecs() - AnimStart
Frame = (TimePassed/MPF) Mod NumFrames
DrawImage(AnimatedImage,X,Y,Frame)
...Some more code


That's off the top of my head, hopefully I didn't confuse you by introducing any mistakes.


Ant(Posted 2006) [#4]
Hmmm...but if my animation system is tied to the internal clock, then it will be the same regardless of the performance of the machine (because 1 millisec = 1 millisec regardless of machine speed?)

[edit]
Don't worry its sunk in - thanks