Sync On:Sync Rate 0:Autocam Off
Position Camera 0,0,10
Set camera range .2,10000
 
Global old_time as DWord
Null=Make Vector3(1)
 
Make_Water_Wheel(1)
Position Object 1,20,0,100
 
Make_Gear(2,20)
Position Object 2,-24,0,114
Make Object Cylinder 3,14
Scale Object 3,100,20,100
Pitch object Up 3,90
Make Mesh from Object 1,3
Delete Object 3
Add Limb 2,9,1
Offset Limb 2,9,0,0,-4
 
Make_Gear(3,20)
Position Object 3,-35,0,102
Turn Object Right 3,90
Roll Object Right 3,15
 
Make_Gear(4,40)
Position Object 4,-55,0,102
Turn Object Right 4,90
Roll Object Right 4,15
Make Object Cylinder 5,2
Scale Object 5,100,1000,100
Pitch Object Down 5,90
Fix Object Pivot 5
Make Mesh from Object 1,5
Delete Object 5
Add limb 4,9,1
Offset Limb 4,9,0,0,10
 
Make_Gear(5,40)
Position Object 5,-33,22,102
Pitch Object Up 5,90
 
Make_Gear(6,80)
Position Object 6,-33,29.5,102
Pitch Object Up 6,90
 
Make_Lever(7,8)
Position Object 7,10,40,60
Rotate Object 7,0,-90,0
 
Make_Gear(8,80)
Position Object 8,-10,0,-5
 
 
 
Make Particles 1,0,100,5
Position Particles 1,40,45,100
Set Particle Floor 1,0
Set Particle Velocity 1,.01
Set Particle Gravity 1,30
Set Particle Life 1,15
Color Particles 1,100,100,255
 
Make Object Sphere 100,200
Scale Object 100,100,100,.01
Position Object 100,0,0,-55
Make Object Triangle 101,-2,0,0,0,99,0,2,0,0
Make Object Triangle 102,-8,0,0,0,89,0,8,0,0
Make Object triangle 103,-9,0,0,0,65,0,9,0,0
Position Object 101,0,0,-56
Position Object 102,0,0,-57
Position Object 103,0,0,-58
Make_Numbers()
For i = 1 to 12
   Position Object 10+i,sin(i*30-2)*90+4,cos(i*30-2)*90+2,-58
Next i
 
Make Object Cylinder 200,500
Offset Limb 200,0,0,250,0
Scale Object 200,100,1000,100
Pitch Object Down 200,90
Position Object 200,0,0,0
Set Object Cull 200,0
Color Object 200,0
Set Object Ambience 200,0
 
Make Object Cylinder 201,500
Offset Limb 201,0,0,250,0
Scale Object 201,120,900,120
Pitch Object Down 201,90
Position Object 201,0,0,0
Set Object Cull 201,0
Color Object 201,0
Set Object Ambience 201,0
 
Make Object Cylinder 202,500
Offset Limb 202,0,0,250,0
Scale Object 202,150,700,150
Pitch Object Down 202,90
Position Object 202,0,0,0
Set Object Cull 202,0
Color Object 202,0
Set Object Ambience 202,0
 
 
Make_Strap(1000)
lever#=0
levdir#=1
 
Do
   If Camera Position Z()<-250
      speed#=5.0
   Else
      speed#=0.2
   Endif
   Move Camera (Upkey()-DownKey())*speed#
   If Camera Position Z()<0 and Camera Position Z()>-5
      Position camera Camera Position X(),Camera Position Y(),-10
   Endif
   If Camera POsition Z()<-5 and Camera Position Z()>-10
      Position camera Camera Position X(),Camera Position Y(),0
   Endif
   lr#=Timer()-old_time
   lvr#=lr#
   lr#=lr#*((360.0/8.0)/1000.0)
   old_time=Timer()
   Roll Object Right 1,lr#
   Roll Object Right 2,lr#
   Roll Object Right 3,lr#
   Roll Object Right 4,lr#
   Roll Object Right 5,lr#
   Roll Object Right 6,lr#
   sa#=Get_Second_Angle()
   Rotate Object 101,0,0,sa#
   ma#=Get_Minute_Angle()
   Rotate Object 102,0,0,ma#
   ha#=Get_Hour_Angle()
   Rotate Object 103,0,0,ha#
   Run_Strap(1000,300,-24,20,-2,110)
   lever#=lever#+(levdir#/lvr#)*90.0
   if abs(lever#)>10
      levdir#=levdir#*-1
      lever#=lever#+(levdir#/lvr#)*90.0
   Endif
   Rotate Object 7,0,-90,0
   Roll Object Right 7,lever#
   Rotate Object 8,0,0,sa#
   Rotate Object 200,0,0,sa#
   Rotate Object 201,0,0,ma#
   Rotate Object 202,0,0,ha#
   Set Cursor 0,0
   Print get time$()
   Sync
Loop
 
 
 
Function Make_Water_Wheel(ObjectID)
   Make Object Cylinder ObjectID,10
   Make Mesh From Object 1,ObjectID
   For i = 1 to 7
      Add Limb ObjectID,i,1
      Offset Limb ObjectID,i,Cos(i*45)*20,Sin(i*45)*20,0
      Rotate Limb ObjectID,i,0,0,i*45
   Next i
   Offset Limb ObjectID,0,20,0,0
   For i = 0 to 3
      Add Limb ObjectID,8+i,1
      Scale Limb ObjectID,8+i,50,320,50
      Rotate Limb ObjectID,8+i,0,0,i*45
   Next i
   Set Object Cull ObjectID,0
Endfunction
 
Function Make_Strap(ObjectID)
   Make Object Plain ObjectID,2,2
   Pitch Object Down ObjectID,90
   Fix Object Pivot ObjectID
   Make Mesh from Object 1,ObjectID
   Delete Object ObjectID
   Make Object ObjectID,1,0
   Add Limb ObjectID,1,1
   Rotate Limb ObjectID,1,0,0,-30
   Set Object Cull ObjectID,0
EndFunction
 
Function Run_Strap(ObjectID,segs,x1#,x2#,y#,z#)
   If Object Exist(ObjectID+1)=0
      Turn Object Left ObjectID,90
      Position Object ObjectID,(x1#+x2#)/2.0,y#-5,z#
      For i = 1 to segs
         Clone Object ObjectID+i,ObjectID
         Position Object ObjectID+i,(x1#+x2#)/2.0,y#+5,z#
         c=rnd(128)+128
         Color Object ObjectID+i,RGB(c,c,c)
      Next i
   Endif
 
   For i = segs to 1 step -1
      Set Vector3 1,Object Position X(ObjectID+i-1)-Object Position X(ObjectID+i),Object Position Y(ObjectID+i-1)-Object Position Y(ObjectID+i),Object Position Z(ObjectID+i-1)-Object Position Z(ObjectID+i)
      d#=Length vector3(1)
      if d#=>1
         Position Object ObjectID+i,Object Position X(ObjectID+i-1),Object Position Y(ObjectID+i-1),Object Position Z(ObjectID+i-1)
         Rotate Object ObjectID+i,Object Angle X(ObjectID+i-1),Object Angle Y(ObjectID+i-1),Object Angle Z(ObjectID+i-1)
      Endif
   Next i
   If Object Position X(ObjectID)<x1# or Object Position X(ObjectID)>x2#
      Pitch Object Up ObjectID,4
   Endif
   Move Object ObjectID,.5
Endfunction
 
Function Make_Gear(ObjectID,size#)
   Make Object Box ObjectID,size#*.08,size#*1.2,size#*.08
   Make Mesh from Object 1,ObjectID
   Delete Object ObjectID
   Make Object Sphere ObjectID,size#
   Scale Object ObjectID,100,100,.1
   Make Mesh From Object 2,ObjectID
   Delete Object ObjectID
   Make Object Cylinder ObjectID,size#
   Scale Limb ObjectID,0,100,11,100
   Pitch Object Down ObjectID,90
   Fix Object Pivot ObjectID
   Make Mesh from Object 3,ObjectID
   Delete Object ObjectID
   Make Object ObjectID,3,0
   Add Limb ObjectID,1,2
   Add Limb ObjectID,2,2
   Offset Limb ObjectID,1,0,0,size#*.05
   Offset Limb ObjectID,2,0,0,size#*-.05
   For i = 0 to 5
      Add Limb ObjectID,3+i,1
      Rotate Limb ObjectID,3+i,0,0,i*30
   Next i
   Set Object Cull ObjectID,0
EndFunction
 
Function Make_Lever(ObjectID,Size#)
   Make Object Box ObjectID,size#,size#,size#*.2
   Rotate Object ObjectID,0,0,45
   Fix Object Pivot ObjectID
   Make Mesh from Object 1,ObjectID
   Delete Object ObjectID
   Make Object Box ObjectID,Size#*10.0,Size#,Size#*.2
   Add Limb ObjectID,1,1
   Offset Limb ObjectID,1,size#*5.0,Size*-.45,0
Endfunction
 
Function Get_Second_Angle()
   t$=Get time$()
   s#=val(right$(t$,2))
   s#=-s#*6.0
Endfunction s#
 
Function Get_Minute_Angle()
   t$=Get time$()
   s#=val(right$(t$,2))
   m#=val(left$(right$(t$,5),2))
   s#=m#*60+s#
   s#=-s#*(6.0/60.0)
Endfunction s#
 
Function Get_Hour_Angle()
   t$=Get time$()
   s#=val(right$(t$,2))
   m#=val(left$(right$(t$,5),2))
   h#=val(left$(t$,2))
   s#=h#*3600.0+m#*60.0+s#
   s#=-s#*(6.0/60.0/12.0)
Endfunction s#
 
 
Function Make_Numbers()
   Ink Rgb(0,0,128),0
   For i=1 to 12
      cls
      Set Cursor 2,2
      Print i
      Get Image i,0,0,20,16,1
      Make Object Plain 10+i,20,20
      Texture Object 10+i,i
      Set Object Transparency 10+i,4
   Next i
Endfunction