While Quel can be a little "harsh" with criticism, I have to agree that it's a very convoluted way of doing it.
This is the most common function I've seen in several other engines for Time Based Movement. (adapted for DBP of course)
global flast# as float
global factor# as float
function tbm_update()
diff# = timer() - flast#
flast# = timer()
factor# = diff# / 1000.0
endfunction
This is all you need. It's simple, and accurate.
move object x, speed# * factor#
Will move the object at a constant speed.
Decoupling the Display Loop from the Game Loop is what Quel was referring to. It allows your game to perform much better while maintaining a steady framerate. This especially helps with multiplayer games where you can't afford to miss any incoming data.
For situations where the framerate tends to fluctuate, you can do this.
global flast# as float
global factor# as float
dim factors(51) as float
function tbm_update()
diff# = timer() - flast#
flast# = timer()
factor# = 0.0
for x = 1 to 49
factors(x) = factors(x+1)
factor# = factor# + factors(x)
next x
factors(50) = diff# / 1000.0
factor# = (factor# + factors(50)) / 50.0
endfunction
This averages the factor# over 50 frames, so your object doesn't jump to it's new position just because the framerate dipped unexpectedly. After less than a second of steady framerate it will be in the right position. During that split second it will still be so close that the difference is negligible.
This also prevents a problem on fast machines where factor# can come back as 0.0 for several frames, which means nothing would move.