I wrote that code years ago but never put it in the codebase. I did post it in code snippets though in October 2003!
Link:
http://forum.thegamecreators.com/?m=forum_view&t=18986&b=6
Example of how to use it:
sync on : sync rate 0 : autocam off
` make some objects
make matrix 1,1000,1000,50,50
make object sphere 1,50 : position object 1,500,0,600 : set object wireframe 1,1
make object cube 2,40
make object cube 3,10 : position object 3,400,5,700
position camera 500,20,400
x#=0
gosub init_timer
do
gosub timer_stuff
` player moves 40 units in 1 second and rotates 90 degrees in one second
control camera using arrowkeys 0,40.0*move#,90.0*move#
` rotate sphere so it rotates 180 degrees in 1 second
turn object left 1,180.0*move#
` bob cube up and down so it takes 1 second
x#=wrapvalue(x#+(360.0*move#))
position object 2,550,50.0*sin(x#),600
` make object chase you at rate of 20 units per second
point object 3,camera position x(),camera position y(),camera position z()
xrotate object 3,0
move object 3,20.0*move#
text 0,20,get time$()
text 0,0,str$(screen fps())
sync
loop
init_timer:
` t9 is how often to change speed (in milliseconds)
t1=timer() : t9=1000
return
timer_stuff:
` don't change any of this!
t2=timer() : inc t3
if t2-t1 >= t9
move#=((t2-t1)/1000.0)/t3 : t1=t2 : t3=0 : t4=1
else
if t4=0 then move#=((t2-t1)/1000.0)/t3
endif
return
It works differently than most peoples as it calculates average frame rate over last 't9' milliseconds and uses that for next 't9' milliseconds. During first 't9' ms it uses average so far. The idea being that differences between frames can sometimes be so quick that you get a dif of zero, and for a split second, your objects wont move. I made it easy to use so you simply multiply object movement by move#. The comments in above code should explain things.
If you want proper timer based movement, you should always have sync rate at 0. This gives people with superfast pcs nice silky smooth games, and those with low spec pcs a playable game.
Ideally you would decrease the t9 value from default of 1 second to get less noticable frame rate jumps.
Remember that code is years old and needs tidying up a bit. As you see, my naming of variables is a bit dodgy!
Boo!