what is frame tweening?

Blitz3D Forums/Blitz3D Beginners Area/what is frame tweening?

Q80(Posted 2003) [#1]
hi all;

I was looking for ways to keep the frame rate steady on any computer and increase it a bit more than what it uses to run. I came across frame tweening and it seems a realy good way to do that. However, i was wondering what are the disadvantages of using this? and what are other cool methods( other thatn frame tweening) that really works for this purpose?


jhocking(Posted 2003) [#2]
The most significant disadvantage is that it is hard to understand and tricky to do. I spent a little time going down that path before I decided on another way to make my game framerate independent. Specifically, I use the delta time method, so named because it depends on keeping track of how much time has elapsed between frames (the delta time) and then scaling everything in your game by that time. In other words, if more time passes between frames then objects have moved further between frames (and vice versa.) This way no matter what the framerate objects move at the same speed (distance per unit time.)

For an example look in the 3D Graphics section of the Code Archives for "Steady Delta Time Routine." There is/was a better example called "No Jitter Delta Time" (or something like that) but I can't seem to find it in the Code Archives. In both examples they correct a common problem in delta time implementations where the delta time jumps around suddenly.


Q80(Posted 2003) [#3]
thanks alot for the help. I'll check that out.


Q80(Posted 2003) [#4]
i have checked it out, its cool for keeping a steady delta, however lets say i want to run my game on any computer at a steady frame rate of 40fps, how do do this? i used tweening, but it kind of tricky like you said. what other ways can i use?

thanks for the help in advance


jhocking(Posted 2003) [#5]
You could just create a timer and use WaitTimer. That's not an ideal way but it is certainly very easy and would keep your game's framerate capped to 40 (or whatever you set the timer to.) Why does your game HAVE to run at 40 however? With delta time the framerate varies but that doesn't matter since the delta factor scales everything in the game according to the framerate.


WolRon(Posted 2003) [#6]
Why does your game HAVE to run at 40 however?


Consistency.
Even though objects may be moving accordingly to time elapsed, it doesn't mean that time feels constant to the player. For example: You write a game that usually runs at 60 fps but occasionally can drop to 40 fps. During the times when the framerate drops, the player can experience what appears to be slowdown even if using delta time adjustments because of the extreme change in framerates (30%). Forcing a 40 fps framerate will keep time elapsed between ALL frames constant and thereby making time FEEL more constant.


jhocking(Posted 2003) [#7]
That's a judgement call I suppose. If you really want to keep at some specific framerate because you think it looks better then use WaitTimer or learn tweening. I still prefer delta time however. It looks pretty smooth to me. Logically there is no apparent slowdown with delta time, except perhaps an apparent strobing at low framerates (which tweening or WaitTimer wouldn't help anyway; the game needs to be optimized so that it will run faster.) Remember, in the delta time technique at lower framerates things move more between frames so the overall movement is exactly the same. To give a specific example, let's say the player is moving at 5 meters/second. At 60 frames/second the player would move .083 meters/frame while at 40 frames/second the player would move .125 meters/frame. Either way the player is moving at a constant 5 meters/second; no faster or slower at different framerates.


Wayne(Posted 2003) [#8]
I'm with jhocking on delta T.


Q80(Posted 2003) [#9]
thanks all for the comments

Sorry guys, i did'nt get the the thing on timer and WaitTimer. How do i set this up for it to run at 40 fps for exmaple?

Thanks in advance


jhocking(Posted 2003) [#10]
At the top of your code:
Global timer=CreatTimer(40)

In the main game loop:
WaitTimer(timer)


Gabriel(Posted 2003) [#11]
You can further increase the smoothness of Delta Time by setting a target number of FPS ( in this case 40 ) and using delay until the required number of milliseconds have passed and it's time to flip. You have to use flip false with this method, but basically you get all the advantages of Delta Time if the target machine is not capable of achieving the desired frame rate, but you also free up system time for windows to do it's thing on systems which can achieve 40fps or more, which eliminates those windowed-mode glitches where the system takes over for a split second and causes a drop in frame rate.


Red Ocktober(Posted 2003) [#12]
this is documented in the Blitz3D manual...

page 17 to 19 me thinks...

--Mike