Speed based on time?

Blitz3D Forums/Blitz3D Programming/Speed based on time?

I'd suggest to use socalled "delta time". It will work with most machines, no matter how slow they are.

Each frame you cacluate the time that was required to render everything. Then you multiply your players waking speed variable with this time parmeter.

eg

t=millisecs()-16

while game
t2=t
t=millisecs()
delta#=float(t-t2)/16.6
...
moveentity player,0,0,stepsize# * delta#
...

Additionally you can use delta to adjust the animation speed of all AnimMeshes automaticly:

Updateworld(delta#)