For example, this code will rotate the cube at the same speed on any machine, whether it can run the program at 20FPS, or 200FPS;
make object cube 1,20
do
a=timer()
xrotate object 1,object angle x(1)+(50*(c#/1000))
text 20,20,str$(screen fps())
sync
b=timer()
c#=b-a
loop
In the key part:
50*(c#/1000), 50 is the amount you want to move the object by (that doesn't mean 50 degrees here, it is just a value). The
(c#/1000) just means that the movement is the same no matter how fast or slow the program is running.
It would be better to make this into a function.
eg:
xrotate object 1,object angle x(1)+Calc(50)
function Calc(value#)
result = value#*(c#/1000))
endfunction result
In this case though, c# would have to be a global value ( global c# at the top of your program)
If you want to test this, add sync rate 20 at the top of the program, run it, then run it with sync rate 200 at the top of the program - voila, cube rotates at the same speed on both (although the cube will rotate more smoothly if the FPS is higher).
Current Project: Retro Compo. Entry.