Sync on
tornadopieces=100
tornadostart=10
Dim x#(tornadopieces)
Dim y#(tornadopieces)
Dim z#(tornadopieces)
Dim xm#(tornadopieces)
Dim zm#(tornadopieces)
x#=0
z#=0
 
for I=tornadostart to tornadostart+tornadopieces
   tempI=i-tornadostart
   make object box i,1*(tempI+2),2,1*(tempI+2)
   position object i,0,tempI*2,0
   yrotate object i, rnd(360)
   xrotate object i, rnd(40)-20
   ghost object on i
   x#(tempI)=0
   y#(tempI)=i*2
   z#(tempI)=0
next I
 
position camera 0,80,-800
point camera 0,40,0
do
   if upkey()=1 then zm#=zm#+.1
   if downkey()=1 then zm#=zm#-.1
   if leftkey()=1 then xm#=xm#-.1
   if rightkey()=1 then xm#=xm#+.1
   xm#=xm#*.95
   zm#=zm#*.95
   x#=x#+xm#
   y#=0
   z#=z#+zm#
   position object tornadostart,x#,y#(0),z#
   x#(0)=x#
   z#(0)=z#
   for i= tornadostart+1 to tornadostart+tornadopieces
      tempi=i-tornadostart
      xm#(tempi)=xm#(tempi)+(x#(tempi-1)-x#(tempi))*.4
      zm#(tempi)=zm#(tempi)+(z#(tempi-1)-z#(tempi))*.4
 
      xm#(tempi)=xm#(tempi)*.5
      zm#(tempi)=zm#(tempi)*.5
 
      x#(tempi)=x#(tempi)+xm#(tempi)
      z#(tempi)=z#(tempi)+zm#(tempi)
      temp#=object angle y(i)
      yrotate object i,wrapvalue(temp#+((100-(i-tornadostart)+rnd(10))*.03))
 
      position object i,x#(tempi),y#(tempi),z#(tempi)
   next i
   sync
loop