do something for 10 seconds

Blitz3D Forums/Blitz3D Programming/do something for 10 seconds

spin wheels for some time, slowing
from an initial speed to zero over time.

dim TurnRate#(4)
;set the initial turnrate for the wheels randomly:
TurnRate#(1)=10.0+rnd(-3.0,3.0) ;degrees per frame to turn higher number mean faster initial spin.
;do the same for indexes 2-4
dim WheelMesh(4)
WheelMesh(1)=mesh
WheelMesh(2)=mesh2 ;this is using your already defined mesh/mesh2/mesh3/mesh4 entities but storing their handles in an array instead, easier to manipulate
WheelMesh(3)=mesh3
WheelMesh(4)=mesh4

Decay#=0.995  ;adjust to any value between 0.0 and 1.0 to change the rate at which they slow down, and therefore changing the amount of time taken for the wheels to come to rest.
repeat

HaveWheelsStopped=true
for i=1 to 4
turnentity WheelMesh(i),TurnRate#(i),0,0 ;only need to alter the pitch why bother altering the yaw and roll unless you are doing something totally different to what I am thinking you are
TurnRate#(i)=TurnRate#(i)*Decay
if TurnRate#(i)<0.1 then TurnRate#(i)=0
if TurnRate#(i)<>0 then HaveWheelsStopped=false
next

renderworld
updateworld
flip
until HaveWheelsStopped=true or keydown(1)