Okay - did a bit of work on this today. New features for v1.2: Stars: give a sense of movement. If, by chance, you do manage to defeat the hoard of drones - you move on to the next level, and have to fight more drones (your shields get refereshed as well).
Enjoy!
Sync On:Sync Rate 60:Autocam Off:Dim ShotTime(200):Dim Chase(200) as Float:Global FireRate:Global ShipHits:ShipHits=1000:Level=0:Color Backdrop 0:#Constant Setup :Clean_AI():Make Mesh from Object 2,2:For i=101 to 200+(Level*10):Make Object Cube i,1:Scale Limb i,0,200,200,500:Restore Offsets:For j =1 to 4:Read lox#,loy#,loz#:Add Limb i,j,2:Offset Limb i,j,lox#,loy#,loz#:Next j:Position Object i,(i*2)-301,-5,0:Set Cursor 0,0:Print i-100:Sync:Next i:If Object Exist(3)=0:Make Object Cube 3,20:Endif:Position Object 3,20,20,400:Point Object 3,0,0,0
Type Coords x as Float,y as Float,z as Float,EndType Global Object As Coords ; Target As Coords ; AI As Coords ; Camera As Coords ; Limb As Coords
StarSkyBox:Do:Setup:Do:E=0:For i = 101 to 200+(Level*10):If Object Exist(i):E=E+1:Roll Object Right i,5.0+rnd(20.0)/100.0:AIM_Missile(i,3):Move Object i,2:AIShoot(i):Endif:Next i:Pitch Object Down 3,Mousemovey():Turn Object Right 3,Mousemovex():Move Object 3,Upkey()*3-Downkey()*1.5:Set_AI(3):Set_Camera():PlayerShoot():Set Cursor 0,0:Ink Rgb(255,255,255),0:Print "Shields: ";ShipHits:Print "Enemies: ";E:Print "Level: ";Level:If ShipHits<1 or E<1:Exit:Endif:Position Mouse Screen Width()/2,Screen Height()/2:Sync:Loop:Main1
Function PlayerShoot():Stars():ObjectID=3:ObFunc:Position Object 4,Object.x,Object.y,Object.z:If MouseClick()=1 And FireRate<1:Ink Rgb(255,0,0),0:Line Screen Width()/2-50,Screen Height(),MouseX(),MouseY():Line Screen Width()/2+50,Screen Height(),MouseX(),MouseY():PO=Pick Object (MouseX(),MouseY(),101,300):If PO>0:Delete Object PO:If Object Exist(PO+200):Delete Object PO+200:Endif:Endif:FireRate=50:Endif:If FireRate>0:FireRate=FireRate-1:Endif:
Endfunction:Function AIShoot(ObjectID):If ShotTime(ObjectID-100)<1:Set_AI(ObjectID):Move Object 2,500:ObFunc:OC#=Intersect Object(3,Object.x,Object.y,Object.z,AI.x,AI.y,AI.z):If OC#>0.0:ObFunc:Make Object Triangle 200+ObjectID,Object.x,Object.y,Object.z,AI.x,AI.y,AI.z,Object.x,Object.y+.05,Object.z:Color Object 200+ObjectID,Rgb(255,0,0):set Object Emissive 200+ObjectID,Rgb(255,0,0)
ShotTime(ObjectID-100)=500:Endif:Else:If ShotTime(ObjectID-100)=498:If Object Exist(ObjectID+200):If Object Collision (ObjectID+200,3)>0:ShipHits=ShipHits-1:Endif:Delete Object ObjectID+200:Endif:Endif:If ShotTime(ObjectID-100)>0:ShotTime(ObjectID-100)=ShotTime(ObjectID-100)-1:Endif:Endif
Endfunction:Function Aim_Missile(ObjectID,TargetID):md#=Squared_Distance(ObjectID,TargetID)+1000:If md#<2000:Chase(ObjectID-100)=-1:Endif:If md#>6000:Chase(ObjectID-100)=1:Endif:L=0:For i = 0 to 4:Set_AI_To_Limb(ObjectID,i):nd#=Squared_Distance(2,TargetID):If nd#<md#:L=i:md#=nd#:Endif:Next i:rn#=5.0+Rnd(200.0)/100.0:Pitch Object Up ObjectID,rn#*Chase(ObjectID-100)*(L=1.0)-rn#*Chase(ObjectID-100)*(L=3.0):Turn Object Right ObjectID,rn#*Chase(ObjectID-100)*(L=2.0)-rn#*Chase(ObjectID-100)*(L=4.0)
Endfunction:Function Set_AI(ObjectID):ObFunc:Position Object 2,Object.x,Object.y,Object.z:Set Object To Object Orientation 2,ObjectID
EndFunction:Function Clean_AI():If Object Exist(2):Delete Object 2:Endif: Make Object Sphere 2,1,6,6:Hide Object 2:Set Object Collision To Boxes 2:Set Object Collision Off 2
EndFunction:Function Set_Object(ObjectID):If Object Exist(ObjectID):If Object Exist(2)=0:Clean_AI():EndIf:ObFunc:Position Object ObjectID,AI.x,AI.y,AI.z:Endif
EndFunction:Function Set_Camera():ObFunc:Position Camera AI.x,AI.y,AI.z:Set Camera To Object Orientation 2
EndFunction:Function Return_Limb(ObjectID,LimbID):If Object Exist(ObjectID):If Limb Exist(ObjectID,LimbID):Limb.x=Limb Position X(ObjectID,LimbID):Limb.y=Limb Position Y(ObjectID,LimbID):Limb.z=Limb Position Z(ObjectID,LimbID):Endif:Endif
EndFunction:Function Set_AI_to_Limb(ObjectID,LimbID):If Object Exist(ObjectID):If Limb Exist(ObjectID,LimbID):If Object Exist(2)=0:Clean_AI():Endif:Return_Limb(ObjectID,LimbID):Position Object 2,Limb.x,Limb.y,Limb.z:Rotate Object 2,Limb Angle X(ObjectID,LimbID),Limb Angle Y(ObjectID,LimbID),Limb Angle Z(ObjectID,LimbID):Endif:Endif
EndFunction:Function Squared_Distance(ObjectID,TargetID):ObFunc:dx#=Object.x-Target.x:dy#=Object.y-Target.y:dz#=Object.z-Target.z:d#=dx#*dx#+dy#*dy#+dz#*dz#
Endfunction d#:Function Stars():For i = 600 to 700:If Object Exist(i):ObjectID=i:If Squared_Distance(3,i)>250000:Delete Object i:Endif:else:Make Object Sphere i,1.5,6,6:Set Object Emissive i,rgb(255,255,255):Set Alpha Mapping On i,70:Position Object i,Object.x,Object.y,Object.z:Turn Object Right i,rnd(360):Pitch Object Up i,rnd(360):Move Object i,rnd(200)+rnd(200)+rnd(200):endif:Next i
Endfunction:#Constant StarSkyBox :If Bitmap Exist(1):Delete Bitmap 1:Endif:Create Bitmap 1,1024,1024:Box 0,0,1023,1023,0,0,0,0:For i = 1 to 500+rnd(500)+rnd(500)+Rnd(500):Dot Rnd(1023),Rnd(1023),Rgb(255,255,255):Next i:Get Image 4,0,0,1023,1023:Set Current Bitmap 0:Make Object Cube 4,-1000:Texture Object 4,4:Set Object Emissive 4,Rgb(255,0,0):set Object Light 4,0:Delete Bitmap 1
#Constant ObFunc :If ObjectID>0:If Object Exist(ObjectID):Object.x=Object Position X(ObjectID):Object.y=Object Position Y(ObjectID):Object.z=Object Position Z(ObjectID):Endif:Endif:If TargetID>0:If Object Exist(TargetID):Target.x=Object Position X(TargetID):Target.y=Object Position Y(TargetID):Target.z=Object Position Z(TargetID):Endif:Endif:AI.x=Object Position X(2):AI.y=Object Position Y(2):AI.z=Object Position Z(2):Camera.x=Camera Position X():Camera.y=Camera Position Y():Camera.z=Camera Position Z()
#Constant Main1 :If E>0:Do:Set Cursor 0,0:Ink Rgb(255,255,255),0:Print "Shields: ";ShipHits:Print "Enemies: ";E:Print "Press [Esc] to use the Escape Pod.":Sync:Loop:Else:Level=Level+1:ShipHits=1000:Endif:Loop:End
Offsets::Data 0,1,-.2,1,0,-.2,0,-1,-.2,-1,0,-.2
"Droids don't rip your arms off when they lose." -H. Solo
REALITY II