Delta Timing keeps giving me shaky graphics
BlitzMax Forums/BlitzMax Beginners Area/Delta Timing keeps giving me shaky graphics
| ||
I spent the afternoon reading about a lot of different ways to control the speed of my game. I tried different code examples i found and they all work except my pictures keep shaking. Does anyone know how to fix this? All the examples i found on fixing the shaking were regarding Max3D which i don't use. |
| ||
please search the forums before you pose a relatively common question such as yours in less than a few minutes of searching the forums for "delta timing" I found one of the best introductory articles on the topic: http://www.gaffer.org/game-physics/fix-your-timestep |
| ||
Does anyone know how to fix this? It's best to provide some code so people can see what might be going wrong.All the examples i found on fixing the shaking were regarding Max3D which i don't use. |
| ||
"please search the forums before you pose a relatively common question such as yours" Seriously, i have spent most of the afternoon searching for a solution on the forum. 80% of the topics i found said what you say "look in the forum". The relevant topics are very old and i tried those but none really adress the shaky graphics. Have you tried a google search? Damn near impossible to find even a relevant site. Thanx for the site though, i'll dive right in. Retracing my steps i saw i looked over the same suggestion made by Muttley. A lot of people have a lot of links beneath their posts, i must have mistaken his suggestion for a personal link (can't find the right word for it). But seriously, i actually do some research before i post a question. "Errrr... nobody uses Max3D ..." Yeah sorry Max3D should be Blitz3D. About the code examples, most i found were different variablenames but the same idea: Local starttime:Int = MilliSecs() Local endtime:Int = MilliSecs() Local diff:Int = endtime - starttime ' Our target framerate is 60 frame per second, it means take each frame must ' last for 1/60 of a second, which is 16.666 millisecond. ' We are going to round that to 17. Local pausedelay:Int = 17-diff If pausedelay > 0 Then Delay(pausedelay) Else pausedelay = 4 End If starttime = endtime+pausedelay Flip(0) *Many variations found on this one or ;place this in initialization Global SpeedFactor#=1.0 Global GameTime=5 Global FrameTime=MilliSecs() ;place this in main loop SpeedFactor#=Float(MilliSecs()-FrameTime)/Float(GameTime) FrameTime=MilliSecs() ;multiply every addition equation by SpeedFactor# x=x+1*SpeedFactor# *Also tried this one but seriously, using the speedfactor on all equations? There must be an easier way. All shaky graphics :( I'll go read gaffer now. |
| ||
There *ARE* lots of different ways of doing it. I have a post about that gaffer's article, I also have some code from a B3D tutorial in the code archives. Nearly ALL the posts are from people who have followed the expected methods but are not happy with the results. Often it's something odd but the important thing is the code you're using. |
| ||
This is not delta timing, this will make your graphics even worse. If you want to fix the framerate, set a fixed refresh rate at the graphics command. Otherwise, if you want to use DeltaTiming, one of the ways to do it is: Global AlphaTime:double Function DeltaCalculate() Global LastTime:int = Millisecs() Local CurTime:int = Millisec() AlphaTime = (CurTime - LastTime) / 10.0 LastTime = CurTime End Function Call DeltaCalculate just after every FLIP command, And multiply any increment on the X or Y by AlphaTime. If should move things at the same speed independently of the hardware FPS. |
| ||
Okay, i did a quick read on Gaffer, i found out that a quick read is far from enough. He's talking about integrating a timestate-thingy which all sounds very interesting and complicated (and i have absolutely no idea how to implement this at the moment). The link about Integration Basics doesn't actually work anymore, this is the corrrect link. I also found a YouTube tutorial of Amcadam26 which uses: Global Timer:TTimer = CreateTimer(60) 'Main loop '.... do stuff... WaitTimer(Timer) Flip The tutorial is about BlitzBasic (not Max) but this actually does what i want without the flickering. Now i have the idea that my problem is solved but it seems too simple. I'll look further into the Timestep way out of curiosity. *took me long enough to type this post to miss tonyg and Ziggy's post, i'll look into it. "multiply any increment on the X or Y by VStep" I don't know what VStep is, all the code i found on the forum when i searched VStep was about scaling an image. |
| ||
it seems to me you are not searching the correct areas... don't use google for this search... in the main forums page of this site don't click "search all forums" in the main forums page do click the "search" just above the "BlitzMax" section (each section has it's own search) do that and search for "jerk", you will find plenty of information on this just for bmax. here are some from that search that you should read: http://www.blitzbasic.com/Community/posts.php?topic=70611#789401 http://www.blitzbasic.com/Community/posts.php?topic=70456#787796 http://www.blitzbasic.com/Community/posts.php?topic=70516#788929 |
| ||
@dmaz: Ha! So simple and yet so much impact. Thanx, i did use 'Search all forums'. Man, what a timesaver. |