Various frame-limiting methods...

Blitz3D Forums/Blitz3D Programming/Various frame-limiting methods...

Odds On(Posted 2003) [#1]
There's quite a few ways to go about keeping things running at the same speed regardless of frame-rate, and after experimenting with a few I have some questions.

Method One: Render Tweening.
Out of all the methods I tried this one seems to give me the smoothest results, but I noticed that to keep the game logic running at a set speed it doesn't always execute the game logic. For example, if you set the framerate to 60fps and it renders at 120fps then the game logic will only be updated every other game loop... my concern is that this could result in key presses and mouse clicks being missed.

Method Two: Delta Time.
I like this method because it's simple, and you don't have to limit the framerate. However, it seems to result in jerky gameplay. To calculate the delta time I just used the difference in MilliSecs() per game loop... I seem to remember that the return value from WaitTimer() can also be used to do it. Would this result in smoother gameplay?

There are other methods as well, but those are the main two I think... what, in your opinion is the best and why?


Kuron(Posted 2003) [#2]
Sorry to hijcak your thread, but your name sounds familiar... You the dude who wrote Dark Matrix many years ago?


Odds On(Posted 2003) [#3]
nope, I've only been programming for about 2 years :)


Andy(Posted 2003) [#4]
I prefer Render tweening... The issue with keyboard and mouse is not something I have experienced.

Andy


podperson(Posted 2003) [#5]
"my concern is that this could result in key presses and mouse clicks being missed"

Your concerns are unwarranted. This is essentially the recommended way to do things, and the way almost every commercial 3D game works (most 3D games have an internal heart beat running at a fixed rate, e.g. 15 fps, and simply render tweens -- for networked games such an approach is almost mandatory).


Paul "Taiphoz"(Posted 2003) [#6]
Id love to see an example of render tweening.

I have used Delta Time a lot and find it works well. but I havent had a chance to look at render tweening.


Who was John Galt?(Posted 2003) [#7]
Yavin - The demo with the chap running around the castle with B3D has render tweening.

Chris- I recently experimented with both methods. DeltaT method seems nicer in some respects but will always be jerky, and if you ever want a game with some physics in it, you can notice you get different results on different machines.

Tweening is definitely the way to go. Nothing can get missed, and your game logic is updating at the rate you set. It is only the gfx that are updated more often (as fast as your machine will provide). The only annoying side effect I have noticed with tweening is where you reposition an entity that you want to instantly jump to a new position. Without tweening that's exactly what you get, but the tweener has no way of knowing you don't want that object tweened. Anyone got any ideas for a workaround?


jhocking(Posted 2003) [#8]
I use delta time. It is only jerky if you use the unaltered frametimes directly. For smooth results you do a simple little calculation for averaging changes; that way things don't jerk around if/when the framerate spikes or something. Look for "no jitter delta time" or something like that in the Code Archives.


Andy(Posted 2003) [#9]
>Id love to see an example of render tweening.

http://www.blitzbasic.com/codearcs/codearcs.php?code=9


Andy


Uhfgood(Posted 2003) [#10]
I've never seen deltatime "jerk" -- And something i'd like to know isn't render-tweening just for rendering? Ie not movement specifically? And if that's the case couldn't you use both? Use deltatime to move your objects based on time, use rendertweening to smooth it out?


Mustang(Posted 2003) [#11]
Steady Delta Time Routine by Chroma


Delta time differs from frame to frame. This routine stabilizes the delta time for more accurate delta time based movment. While working on Luftwaffe Ace 1946, I noticed this was a big problem because all objects are moved on delta time. This wipes it out and works great for me!


http://www.blitzbasic.com/codearcs/codearcs.php?code=431


Odds On(Posted 2003) [#12]
I think Im gonna go with the render tweening, but without the tweening and see how that goes.


Paul "Taiphoz"(Posted 2003) [#13]
Well I use Delta Time, and I also take the average to smoth things out, What really bugs me about it though is the collisions problems you can come accross in 2D.

So IM going to add Render Tweening to my current 3D project and look into a way on adding it to 2D.. any ideas?


jfk EO-11110(Posted 2003) [#14]
I vote for Delta. BTW: when you tween the Movement and you have -say a given "internal heartbeat" of 15 fps and a physical screen vsync rate of say 70 hz - doesn't this mean that you cannot sync your movement correctly with the syncrate?


ronbravo(Posted 2003) [#15]
There is a render tweening tutorial at the Blitz Coder website under tutorials.


John Blackledge(Posted 2003) [#16]
Render Tweening worked for me.
Basically my 'town' was so busy that the fps occasionally dropped under the desired 30 fps, but thanks to render tweening my characters always walked smoothly, as designed, and got from a to b in the exact time specified.


Ice9(Posted 2003) [#17]
I'm Also with the Delta Time and averaging
and never use the Flip False with it unless I want to
know the true framerate. Flip False will cause jitters.


Wayne(Posted 2003) [#18]
I'm with Delta Time.


Boiled Sweets(Posted 2003) [#19]
I have tried the render tweening example
(www.blitzbasic.com/codearcs/codearcs.php?code=9 ) on my game with the fps set at 50 and get a FPS of 10, if I turn it off I get a FPS of 20.

I've also tried the smart frame limiting example (www.blitzbasic.com/codearcs/codearcs.php?code=749), that seems to work better but has "Delay" command in it, doesn't that intruduce jerkyness?

Is the render tweening example the proven method limiting FPS?


SabataRH(Posted 2003) [#20]
The debate between Delta-Timing and Render-Tweening has been going on for quite awhile... As i recall the community was divided in half and no general solution had been reached.

Theres no real 'right' or 'wrong' method to handle your tweening. Its going to come down to preference and what you feel most comfortable using...

With that said, my choice in frame-limiting is 'Render-Tweening'.. Having tried both methods; I just felt like things were more reliable under render-tweening.. Both methods introduce their own probelms, and both present their own advantages... So make a pick and stick with it! :)>>