Or you can use doubles isntead of floats. (I do for my timing)
Anyway I'm interested in doing the same sort of thing for my framework soon. Basically on my PC everthing is dead smooth (delta is the same each frame), but it's not the same on *some* other PCs.
Some people have frequent peaks followed by troughs (in BMax), so like instead of it taking 16ms per frame (@60Hz) they get 48ms for one frame followed by two frames of 0ms! This really screws with the game smoothness because the frame before the peak will get shown for at least 48ms and then the delta time says "whoa, better make a big jump to catch up" and it shifts the object a long way.
I found that it actually looks better if delta time doesn't catch up as much (or at all). But if you don't catch up at all, and you have a game timer, it'll loose time. So I'm wondering about catching up say half the amount, and then spreading the other half over the following frames (the 0ms frames for example). But I haven't implemented it yet.
Don't know if that makes sense...
I read swift's code and it appears to react to changes in FPS over 1/8 second. My proposal would be to take instant action and then spread the "load" over the next few frames. Don't know if it'll work yet...
It still won't look perfect because at the end of the day, if 3 frames are missed (for example) because of a background task, the object is still going to sit there for 3 frames before jerking forward. It's just how *much* it jerks that I'm intending to modify.
I'm interested that you are getting jerks in BPlus. I was beginning to think that jerks only existed in BMax. I was going to write a Bplus version of my jerk tester, but perhaps you could convert this code?
'SetGraphicsDriver GLMax2DDriver()
Graphics 800,600,32
'Graphics 800,600,0
Local t1:Int
Local t2:Int
Local test: Int
Local high: Int
Local lo:Int = 200
Const MAXVALUES=800
Local values:Int[MAXVALUES]
Local counter=0
Local loops = 0
Local average = 0
Local total = 0
While Not KeyHit(KEY_ESCAPE)
t1=MilliSecs()
Cls
DrawText "Current: "+test,0,0
DrawText "High: "+high,0,20
DrawText "Low: "+lo,0,40
DrawText "Average: "+average,0,60
DrawText "Press <Space> to reset High",0,80
DrawText "Press <Escape> to exit",0,100
' DrawText GCMemAlloced(),0,80
For Local i=0 To MAXVALUES-2
SetColor 255,255,0
DrawLine 0,500,800,500
SetColor 255,255,255
DrawLine i,500-values[i],(i+1),500-values[i+1]
Next
Flip 1
t2 = MilliSecs()
test:Int = (t2-t1)
If test>high Then high = test
If test<lo Then lo = test
If KeyHit(KEY_SPACE)
high = 0
lo = 200
loops = 0
average = 0
total = 0
End If
values[counter] = test
Counter:+1
If counter>=MAXVALUES Then counter = 0
loops :+ 1
total :+ test
average = total/loops
Wend
See if you get a smooth line (give or take 1 pixel) or a line with peaks and troughs.
One small point, maybe you are just seeing moire effect on your moving objects. For example, if something moves exactly 1 pixel per frame and your frame rate is 60HZ, it will always look dead smooth (unless a background task prevents it moving for a frame or two). However, using delta time means that some frames it may move 1 pixel, and others 0 and others 2 etc. (due to rounding a float to integer coords) The net result is that it will have moved an average of 1 pixel per frame (if that's the speed you've set it to), but it may look a tiny bit jerky.
If you use BMax it can draw at NON-Integer coords using a bit of video card jiggery pokery (smoothing) and that can look pretty neat (if you setup your sprites to handle that).