Constant Framerate
Constant Framerate
Not a major issue but if there is a way around it i'd love to know.
A small test game runs the same speed on both Linux and Windows, but is slightly jumpy. the average Framerate is constant but the actual framerate fluctuates visibly.
Does anyone know a method to keep everything running perfectly smooth?
A small test game runs the same speed on both Linux and Windows, but is slightly jumpy. the average Framerate is constant but the actual framerate fluctuates visibly.
Does anyone know a method to keep everything running perfectly smooth?
Well, in QB, TIMER was limited to 18.2 ticks a second, and SLEEP was done in seconds. However, FB's timer is kickass, and sleep operates in milliseconds. So you can do something like this:
At least I think that works. Completely untested.
Code: Select all
Dim As Double now
Dim As Double oneFrame
oneFrame = 1/60 '1/60th of a second
Do While gameIsRunning
now = Timer
' Do Stuff
If Timer < (now + oneFrame) Then Sleep ((now + oneFrame) - Timer) * 1000
Loop
I'm using a very similar approach allready, please take a look at the code
www.langfordtavern.com/dev/media/file/geoduel.zip
when run, its not too bad, but it isn't really smooth flowing
www.langfordtavern.com/dev/media/file/geoduel.zip
when run, its not too bad, but it isn't really smooth flowing
good ol' sprintf, from crt.bi, should help you :)
Code: Select all
#include crt.bi
dim number as double
dim somestring as string*5
number = 23.3582930485902385#
sprintf strptr(somestring), strptr("%5f"), number
print somestring
sleep