Sync On:Sync Rate 0:Autocam Off #Constant VelMomentum 1 #Constant SpinMomentum 2 #Constant ShipPos 3 Null=Make Vector3(VelMomentum) Null=Make Vector3(SpinMomentum) Null=Make Vector3(ShipPos) Global LastTime as Dword Global CycleTime as DWord Global TimeFactor as Float Global Grav as Float Global Fric as Float Global Thrust as Float Grav=-32 Fric=.9998 Make_Ship(1) Set Object Collision On 1 Do Position Object 1,0,50,80 Rotate Object 1,0,0,0 Set_Vector_To_Object( ShipPos ,1) Make_Landing_Pad(2,-15,-30,75,20,20) Do `Control Ship Thrust = ( ka + kd + ko + km) * TimeFactor * 15.0 `Right Thruster Set Vector3 SpinMomentum , VX (SpinMomentum), VY (SpinMomentum), VZ (SpinMomentum)- ka * TimeFactor * 10.0 if ka Then Fire_Particle(1,8) `Left Thruster Set Vector3 SpinMomentum , VX (SpinMomentum), VY (SpinMomentum), VZ (SpinMomentum)+ kd * TimeFactor * 10.0 if kd Then Fire_Particle(1,6) `Close Thruster Set Vector3 SpinMomentum , VX (SpinMomentum)+ km * TimeFactor * 10.0, VY (SpinMomentum), VZ (SpinMomentum) if km Then Fire_Particle(1,7) `Far Thruster Set Vector3 SpinMomentum , VX (SpinMomentum)- ko * TimeFactor * 10.0, VY (SpinMomentum), VZ (SpinMomentum) if ko Then Fire_Particle(1,5) `Apply spin momentum Rotate Object 1, OAX (1) + VX (SpinMomentum) * TimeFactor , OAY (1) + VY (SpinMomentum)* TimeFactor , OAZ (1) + VZ (SpinMomentum)* TimeFactor `Apply Thrust Move Object Up 1,Thrust `Apply Momentum x#= VX (VelMomentum)*timefactor: y#= VY (VelMomentum)*timefactor : z# = VZ (VelMomentum)*timefactor Position Object 1, OPX (1) + x#, OPY (1) + y#, OPZ (1) + z# `Apply Gravity Position Object 1, OPX (1), OPY (1) + Grav*TimeFactor , OPZ (1) `Update Momentum mx#= (OPX (1) - VX (ShipPos)) my#= (OPY (1) - VY (ShipPos)) mz#= (OPZ (1) - VZ (ShipPos)) Set Vector3 VelMomentum , mx# , my# , mz# Set_Vector_To_Object( ShipPos ,1) Move_Particles() L=Check_Landing(2) If Abs(L)>0 then Exit Update_Cycle_Time Set Cursor 0,0 Print "Falling Velocity: ";VY (VelMomentum) Sync Loop Delete Objects 1000,2000 Do Set Cursor 0,0 If L<0 Print "You Have Landed Safely" Else Print "You Have Crashed" Endif Print Print "Press the Space Key to continue" Print OPX (1)< OPX (2) - (Object Size X(2)/2.0) Print OPX (1)> OPX (2) + (Object Size X(2)/2.0) Print OPZ (1)< OPZ (2) - (Object Size Z(2)/2.0) Print OPZ (1)> OPZ (2) + (Object Size Z(2)/2.0) If Spacekey() Then Exit Sync Loop Set Vector3 1,0,0,0 Set Vector3 2,0,0,0 Set Vector3 3,0,0,0 Loop Function Set_Vector_To_Object(Vector,obj) Set Vector3 Vector, OPX (obj), OPY (obj), OPZ (obj) Endfunction Function Make_Ship(obj) Make Object Cylinder obj,1 Make Mesh From Object 1,obj Delete Object obj Make Object Sphere obj,4.5 Add Limb obj,1,1 Scale Limb obj,1,100,300,100 Rotate Limb obj,1,90,0,0 Offset Limb obj,1,0,0,3.5 Add Limb obj,2,1 Scale Limb obj,2,100,300,100 Rotate Limb obj,2,90,0,0 Offset Limb obj,2,0,0,-3.5 Add Limb obj,3,1 Scale Limb obj,3,100,300,100 Rotate Limb obj,3,0,0,90 Offset Limb obj,3,-3.5,0,0 Add Limb obj,4,1 Scale Limb obj,4,100,300,100 Rotate Limb obj,4,0,0,90 Offset Limb obj,4,3.5,0,0 For i = 0 to 3 Add Limb obj,5+i,1 Scale Limb obj,5+i,100,400,100 x#=Sin(i*90.0)*4.5:z#=Cos(i*90.0)*4.5 Offset Limb obj,5+i,x#,-1.5,z# Next i Set Object Cull obj,0 Endfunction Function Make_Landing_Pad(Obj,px#,py#,pz#,sx#,sz#) If Object Exist(obj) Then Delete Object obj Make Object Box Obj,sx#,.5,sz# Position Object Obj,px#,py#,pz# Endfunction Function Check_Landing(PadObj) If OPY (1)<-50 Then ExitFunction 1 If Object Collision(1,PadObj)=0 Then ExitFunction 0 Crash=-1 If Abs( OAX (1))>10 Then Crash=1 If Abs( OAZ (1))>10 Then Crash=1 If Abs( VY (VelMomentum))> .01 Then Crash=1 If OPX (1)< OPX (PadObj) - (Object Size X(PadObj)/2.0) then Crash=1 If OPX (1)> OPX (PadObj) + (Object Size X(PadObj)/2.0) then Crash=1 If OPZ (1)< OPZ (PadObj) - (Object Size Z(PadObj)/2.0) then Crash=1 If OPZ (1)> OPZ (PadObj) + (Object Size Z(PadObj)/2.0) then Crash=1 If Crash = -1 Then Rotate Object 1,0, OAY (1),0 Endfunction Crash Function Roll_Object_Right(obj,ang#) Rotate Object obj, OAX (obj), OAY (obj), OAZ (obj)-ang# Endfunction Function Roll_Object_Left(obj,ang#) Rotate Object obj, OAX (obj), OAY (obj), OAZ (obj)+ang# Endfunction Function Turn_Object_Right(obj,ang#) Rotate Object obj, OAX (obj), OAY (obj)-ang#, OAZ (obj) Endfunction Function Turn_Object_Left(obj,ang#) Rotate Object obj, OAX (obj), OAY (obj)+ang#, OAZ (obj) Endfunction Function Pitch_Object_Down(obj,ang#) Rotate Object obj, OAX (obj)+ang#, OAY (obj), OAZ (obj) Endfunction Function Pitch_Object_Up(obj,ang#) Rotate Object obj, OAX (obj)-ang#, OAY (obj), OAZ (obj) Endfunction Function Fire_Particle(Obj,Limb) P=Free_Particle() If P=0 Then Exitfunction Position Object P,Limb Position X(obj,limb) + (rand * 2.0 - 1.0),Limb Position Y(obj,limb) - 2.0,Limb Position Z(obj,limb) + (rand * 2.0 - 1.0) Rotate Object P,Limb Direction X(obj,limb)+90,Limb Direction Y(obj,limb),Limb Direction Z(obj,limb) Endfunction #Constant Move_Particles Move_Particles() Function Move_Particles() For i = 1000 to 2000 If Object Exist(i) If Object Visible(i) Move Object i,.1 Roll Object Right i,2 Offset Limb i,0,0,Limb Offset Y(i,0)-.01,0 if i = 1000 Print Limb Offset Y(i,0) Endif If Limb Offset y(i,0)<-.5 Hide Object i Offset Limb i,0,0,0,0 Endif Endif Endif Next i Endfunction #Constant Free_Particle Free_Particle() Function Free_Particle() Flag=0 For i = 1000 to 2000 If Object Exist(i)=0 Make_Particle(i) Flag=1 Exit Else If Object Visible(i)=0 Show Object i Flag=1 Exit Endif Endif Next i i=Flag*i Endfunction i Function Make_Particle(P) Make Object Triangle P, -.5,1,0, 0,0,0, 0.2,1,0.2 If Image Exist(1000)=0 Box 0,0,64,64,RGB(128,0,0),RGB(128,128,0),RGB(255,128,0),RGB(211,224,254) For i = 1 to 200 Dot Rnd(64),Rnd(64),Rgb(255,0,0) Next i Get Image 1000,0,0,64,64,0 Endif Texture Object P,1000 Set Object Cull P,0 Ghost Object On P Set Object Emissive P,Rgb(255,100,100) Endfunction #Constant Update_Cycle_Time :CycleTime=Timer()-LastTime:LastTime=Timer():TimeFactor=CycleTime/1000.0:If TimeFactor>.99:TimeFactor=.99:Endif: #Constant rand Rnd(10000.0)/10000.0 `keystate abreviations #Constant k1 keystate(2) #Constant k2 keystate(3) #Constant k3 keystate(4) #Constant k4 keystate(5) #Constant k5 keystate(6) #Constant k6 keystate(7) #Constant k7 keystate(8) #Constant k8 keystate(9) #Constant k9 keystate(10) #Constant k0 keystate(11) #Constant ka keystate(30) #Constant kb keystate(48) #Constant kc keystate(46) #Constant kd keystate(32) #Constant ke keystate(18) #Constant kf keystate(33) #Constant kg keystate(34) #Constant kh keystate(35) #Constant ki keystate(23) #Constant kj keystate(36) #Constant kk keystate(37) #Constant kl keystate(38) #Constant km keystate(50) #Constant kn keystate(49) #Constant ko keystate(24) #Constant kp keystate(25) #Constant kq keystate(16) #Constant kr keystate(19) #Constant ks keystate(31) #Constant kt keystate(20) #Constant ku keystate(22) #Constant kv keystate(47) #Constant kw keystate(17) #Constant kx keystate(45) #Constant ky keystate(21) #Constant kz keystate(44) #Constant OAX Object Angle X #Constant OAY Object Angle Y #Constant OAZ Object Angle Z #Constant OPX Object Position X #Constant OPY Object Position Y #Constant OPZ Object Position Z #Constant VX X Vector3 #Constant VY Y Vector3 #Constant VZ Z Vector3