oh yeah that's a delta time approach, not tweening. I don't know what all the framecounter junk is about though, I think that's just to display the framerate and not actually part of the delta time. Also, the delta time calculation there will be jittery because it changes so much every frame; it's generally a good idea to smooth out delta time by averaging it over several frames.
Basically, delta time is about figuring out how much time passes between frames and then multiplying all your changes by that time. If the framerate is low then delta time is larger, so when multiplying by that the amount of change between frames will be greater. Conversely, if the framerate is high then delta time will be low and there will be less change between frames. The result is the same amount of change over a given length of time no matter what the framerate is.
I think I have some demo code of something simple I slapped together a long time ago that includes delta timing, lemme see here...
ADDITION: man I can't believe this thing is still on my server, I just found it in a post from 2003 by searching the forum: http://www.moondoggieent.com/downloads/ninja_test.zip Hit Z to jump and X to attack. I don't know why the animation frames are all messed up, it certainly looked great 4 years ago when I wrote this.
Notice how the main loop is calculating something called "frametime" and every movement is multiplied by that variable?
|