`By Patrick Lewis 20/Feb/2005 Type Coordinates x as Float y as Float z as Float Endtype Global Object As Coordinates Global Target as Coordinates Global AI as Coordinates Global Camera as Coordinates Type Attributes Energy as Integer Armor as Integer Health as Integer Damage as Integer Range as Integer Ablative as Integer Shield as Integer Pos as Coordinates Weapon as String Weap_ID as Integer Speed as Float Object_Num as Integer Velocity as Float Color as DWord EndType Global Robot as Attributes Global Robot_Rating as Integer Dim Enemy(20) as Attributes Dim Enemy_Rating(20) as Integer Type Weapons Weapon_ID as Integer Weapon_Name as String Weapon_Damage as Integer Weapon_Range as Integer EndType Global Robot_Weapon as Weapons Dim Enemy_Weapon(20) as Weapons Type Bullets Bullet_Damage as Integer Bullet_Range as Integer Bullet_Area as Integer Bullet_Speed as Integer Bullet_Object as Integer Bullet_Target as Coordinates EndType Global Robot_Bullet as Bullets Dim Enemy_Bullet(20) as Bullets Sync On Sync Rate 60 Autocam Off Do Flush Video Memory Global Level as Float Global NextLevel as Float Global Score as Integer Global EnemyCount as Integer Global Special As Integer Global Special$ as String Global Kills as Integer Global Shots as Float Global Hits as Float Global SkillHits as Float Global Accuracy as Float Position Camera 0,0,0 Rotate Camera 0,0,0 Set Camera Range 5,1000 Start_Menu() Hide Mouse Level =1 Score = 0 NextLevel=100 EnemyCount=0 Kills=0 Robot_Rating=Make_Robot(1) Make_Crosshair() Make_Road() Make_X_Road() Return_Object(1) Position Camera 0,Object.y+100,50 Point Camera 0,0,51 Position Object 501,0,-8,60 Position Object 502,0,-8,60+174 Do Move_Roads() Move_Special() Move_Robot() Start_Enemy() If Move_Enemy() Then Exit Move_Crosshair() If Mouseclick()=1 Return_Target(3) Make_R_Bullet(Target.x,0,Target.z) Endif Move_R_Bullet() Ink RGB(171,180,254),0 Print_Stats() Sync Loop Print_Stats() Center Text Object Screen X(1),Object Screen Y(1)-20,"Game Over. Press the anykey to play again" Sync Sleep 1000 Clear Entry Buffer Wait Key For i = 1 to 5000 If Object Exist(i) Then Delete Object i If Image Exist(i) Then Delete Image i Next i Loop Function Print_Stats() Ink RGB(171,180,254),0 Set Cursor 0,0 Print "Score: ";Score If Score>NextLevel Level=Level+1 NextLevel=NextLevel+(Level*100) Endif Print "Level: ";Level Ink Rgb(255-Robot.Health*2,50,55+Robot.Health*2),0 Print "Health: "; Robot.Health Ink RGB(179,188,251),0 Print "Armor: "; Robot.Armor Print "Range: +"; Robot.Range Print "Speed: +"; Robot.Speed Print "Damage: +"; Robot.Damage Ink Rgb(255,0,0),0 Print "Kills: "; Kills Accuracy=Int(Hits/Shots*100) Ink Rgb(0,0,255),0 Print "Accuracy: " ; Accuracy ; "%" EndFunction Function Make_Robot(ObjectID) If Object Exist (ObjectID) Then Delete Object ObjectID Make Object Cube ObjectID,5 If Object Exist(2) Then Delete Object 2 If Mesh Exist(2) Then Delete Mesh 2 Make Object Sphere 2,5 Make Mesh From Object 2,2 Add Limb ObjectID,1,2 Offset Limb ObjectID,1,0,4,0 Delete Mesh 2 Delete Object 2 Make Object Cylinder 2,4 Scale Object 2,30,100,30 Offset Limb 2,0,0,2,0 Roll Object Right 2,100 Fix Object Pivot 2 Make Mesh From Object 2,2 Add Limb ObjectID,2,2 Add Limb ObjectID,3,2 Offset Limb ObjectID,2,0,1,-3 Offset Limb ObjectID,3,0,1,3 Color Limb ObjectID,2,RGB(128,128,128) Color Limb ObjectID,3,RGB(128,128,128) Delete Mesh 2 Delete Object 2 Make Object Cylinder 2,10 Scale Object 2,100,20,20 Pitch Object Down 2,90 Fix Object Pivot 2 Make Mesh From Object 2,2 Add Limb ObjectID,4,2 Add Limb ObjectID,5,2 Offset Limb ObjectID,4,0,-3,-3 Offset Limb ObjectID,5,0,-3,3 Delete Object 2 Delete Mesh 2 Make Object Sphere 2,10 Scale Object 2,100,20,1 Make Mesh from Object 2,2 Add Limb ObjectID,6,2 Add Limb ObjectID,7,2 Offset Limb ObjectID,6,0,-3,-3.9 Offset Limb ObjectID,7,0,-3,3.9 Delete Object 2 Delete Mesh 2 Set Object Cull ObjectID,0 Turn Object Left ObjectID,90 Fix Object Pivot ObjectID Color Object ObjectID,Robot.Color If Bitmap Exist(1) Then Delete Bitmap 1 Create Bitmap 1,100,20 Set Current Bitmap 1 Ink RGB(210,210,210),0 Box 0,0,99,19 Ink Rgb(40,40,40),0 For i = 0 to 90 step 10 Box i,0,i+1,19 Next i Get Image 1,0,0,99,19 Delete Bitmap 1 Texture Limb ObjectID,4,1 Texture Limb ObjectID,5,1 Set Object Collision Off ObjectID Robot.Health=100 Robot.Object_Num=1 Robot.Speed=0 Robot.Damage=0 Robot.Armor=0 Robot.Range=0 Set Object Collision to Boxes ObjectID EndFunction R Function Move_Robot() YRotate Object 1,0 Return_Object(1) Make_AI() Position Object 2,Object.x,Object.y,Object.z Set Object To Object Orientation 2,1 Move Object Left 2,((LeftKey()*(Object Screen X(1)>20))-(RightKey()*(Object Screen X(1)<(Screen Width()-20)))) Move Object 2,(Upkey()*(Object Screen Y(1)>Screen Height()*.1)-DownKey()*(Object Screen Y(1)<Screen Height()-40)) Return_AI() If (AI.x<>Object.x) or (AI.z<>Object.z) Point Object 1,AI.x,Object.y,AI.z Move Object 1,.8+(Robot.Speed/10) Endif YRotate Object 1,RightKey()*45-LeftKey()*45 Scroll Limb Texture 1,4,-.005,0 Scroll Limb Texture 1,5,-.005,0 Minimap(1,RGB(119,119,255)) EndFunction Function Make_AI() If Object Exist (2) then Delete Object 2 Make Object Sphere 2,1,10,10 Set Object Collision Off 2 Hide Object 2 Endfunction Function Make_R_Bullet(Tx#,Ty#,Tz#) If Object Exist(101) Then ExitFunction Make Object Sphere 101,2 Robot_Bullet.Bullet_Damage=rnd(4+Robot.Damage)+1 Robot_Bullet.Bullet_Range=50+(Robot.Range*2) Robot_Bullet.Bullet_Area=5 Robot_Bullet.Bullet_Speed=6 Robot_Bullet.Bullet_Object=101 Robot_Bullet.Bullet_Target.x=Tx# Robot_Bullet.Bullet_Target.y=Ty# Robot_Bullet.Bullet_Target.z=Tz# Return_Object(1) Position Object 101,Object.x,Object.y,Object.z Point Object 101,Tx#,Ty#,Tz# Shots=Shots+1 EndFunction Function Move_R_Bullet() If Object Exist(101)=0 then ExitFunction Speed=Robot_Bullet.Bullet_Speed If Speed=0 then Speed=1 For i = 1 to Speed If Robot_Bullet.Bullet_Speed>0 Then Move Object 101,1 Robot_Bullet.Bullet_Range=Robot_Bullet.Bullet_Range-1 If Robot_Bullet.Bullet_Range=0 Robot_Bullet.Bullet_Speed=0 scale=Robot_Bullet.Bullet_Area/Object Size(101)*100 Robot_Bullet.Bullet_Damage=Robot_Bullet.Bullet_Damage*3 Scale Object 101,scale,scale,scale Color Object 101,Rgb(255,0,0) Ghost Object On 101 Endif HitEnemy=Object Collision(101,0) If HitEnemy>1000 and HitEnemy<1021 Hits=Hits+1 If Object Size(101)>2 Then SkillHits=SkillHits+1 Enemy(HitEnemy-1000).Health=Enemy(HitEnemy-1000).Health-Robot_Bullet.Bullet_Damage If Enemy(HitEnemy-1000).Health<1 Return_Object(HitEnemy) Delete Object HitEnemy EnemyCount=EnemyCount-1 Kills=Kills+1 If rnd((Level^2)*10)<Accuracy/2 Then Make_Special(Object.x,Object.z) Endif Delete Object 101 Score=Score+Robot_Bullet.Bullet_Damage ExitFunction Endif If Robot_Bullet.Bullet_Range<-10 Delete Object 101 ExitFunction Endif Next i EndFunction Function Make_Crosshair() If Object Exist (3) Then Delete Object 3 Make Object Cylinder 3,10 If Mesh Exist(2)Then Delete Mesh 2 Make Mesh From Object 2,3 Add Limb 3,1,2 Add Limb 3,2,2 Delete Mesh 2 Rotate Limb 3,1,0,0,90 Rotate Limb 3,2,90,0,0 Scale Limb 3,0,10,100,10 Scale Limb 3,1,10,100,10 Scale Limb 3,2,10,100,10 Pitch Object Down 3,90 Fix Object Pivot 3 Color Object 3,Rgb(255,0,0) Position Object 3,0,5,0 Set Object Cull 3,0 Set Object Collision Off 3 Ghost Object On 3 EndFunction Function Move_Crosshair() mx=MouseX():my=MouseY() cntr=0 Do cx=Object Screen X(3): cy=Object Screen Y(3) If cx=mx and cy=my then Exit Move Object Left 3,((cx>mx)-(cx<mx))*.2 Move Object 3,((cy>my)-(cy<my))*.2 cntr=cntr+1 If cntr>40 Then Exit Loop Roll Object Left 3,1 Fix Object Pivot 3 EndFunction Function Make_Enemy_Robot(ObjectID,ERID) Make Object Cube ObjectID,5 If Object Exist(2) Then Delete Object 2 If Mesh Exist(2) Then Delete Mesh 2 Make Object Sphere 2,5 Make Mesh From Object 2,2 Add Limb ObjectID,1,2 Offset Limb ObjectID,1,0,4,0 Delete Mesh 2 Delete Object 2 Make Object Cylinder 2,4 Scale Object 2,30,100,30 Offset Limb 2,0,0,2,0 Roll Object Right 2,100 Fix Object Pivot 2 Make Mesh From Object 2,2 Add Limb ObjectID,2,2 Add Limb ObjectID,3,2 Offset Limb ObjectID,2,0,1,-3 Offset Limb ObjectID,3,0,1,3 Delete Mesh 2 Delete Object 2 Make Object Cylinder 2,10 Scale Object 2,100,20,20 Pitch Object Down 2,90 Fix Object Pivot 2 Make Mesh From Object 2,2 Add Limb ObjectID,4,2 Add Limb ObjectID,5,2 Offset Limb ObjectID,4,0,-3,-3 Offset Limb ObjectID,5,0,-3,3 Delete Object 2 Delete Mesh 2 Make Object Sphere 2,10 Scale Object 2,100,20,1 Make Mesh from Object 2,2 Add Limb ObjectID,6,2 Add Limb ObjectID,7,2 Offset Limb ObjectID,6,0,-3,-3.9 Offset Limb ObjectID,7,0,-3,3.9 Delete Object 2 Delete Mesh 2 Set Object Cull ObjectID,0 Turn Object Left ObjectID,90 Fix Object Pivot ObjectID Color Object ObjectID,RGB(128,0,0) Color Limb ObjectID,2,RGB(128,128,128) Color Limb ObjectID,3,RGB(128,128,128) Texture Limb ObjectID,4,1 Texture Limb ObjectID,5,1 Set Object Collision to Boxes ObjectID Enemy(ERID).Health=10+Rnd(Level*2) Enemy(ERID).Object_Num=ObjectID EndFunction R Function Start_Enemy() If Rnd(800)>Level+((Level-EnemyCount)*2) Then ExitFunction For i = 1001 to 1020 If Object Exist(i)=0 Make_Enemy_Robot(i,i-1000) EnemyCount=EnemyCount+1 Position Object i,((rnd(400)-200)+(rnd(400)-200))/2,0,125+Rnd(200) Turn Object Right i,180 Exit Endif Next EndFunction Function Move_Enemy() Make_AI() Dead=0 Set Object Collision On 1 For i = 1 to 20 If Object Exist(1000+i) Return_Object(1000+i) Return_Target(1) Position Object 2,Object.x,Object.y,Object.z Set Object To Object Orientation 2,1000+i Move Object 2,10 Point Object 2,Target.x,Object.y,Target.z Move Object 2,Rnd(3) Return_AI() Point Object 1000+i,AI.x,Object.y,AI.z Move Object 1000+i,.75 Scroll Limb Texture 1000+i,4,-.005,0 Scroll Limb Texture 1000+i,5,-.005,0 Minimap(1000+i,RGB(255,0,0)) If Object Collision (1000+i,1) Dead=1 Set Object Collision Off 1 ExitFunction Dead Endif Endif Enemy_Shoot(i) If Move_E_Bullet(i) Then ExitFunction 1 Next i Set Object Collision Off 1 EndFunction Dead Function Enemy_Shoot(ERID) If Object Exist(1000+ERID)=0 Then ExitFunction If rnd(2000)<Level*50 Return_Object(1000+ERID):Return_Target(1) Dist#=(Object.x-Target.x)^2+(Object.z-Target.z)^2 If Dist#<55^2 aimx#=rnd(20-(level/6))-(10-(level/3))+Target.x aimz#=rnd(20-(level/6))-(10-(level/3))+Target.z Make_E_Bullet(ERID,aimx#,target.y,aimz#) Endif Endif EndFunction Function Make_E_Bullet(ERID,Tx#,Ty#,Tz#) If Object Exist(2000+ERID) Then ExitFunction If Object Exist(1000+ERID)=0 Then ExitFunction Make Object Sphere 2000+ERID,2 Enemy_Bullet(ERID).Bullet_Damage=rnd(Level/2)+1 Enemy_Bullet(ERID).Bullet_Range=47+Level/3 Enemy_Bullet(ERID).Bullet_Area=3 Enemy_Bullet(ERID).Bullet_Speed=3 Enemy_Bullet(ERID).Bullet_Object=2000+ERID Enemy_Bullet(ERID).Bullet_Target.x=Tx# Enemy_Bullet(ERID).Bullet_Target.y=Ty# Enemy_Bullet(ERID).Bullet_Target.z=Tz# Return_Object(1000+ERID) Position Object 2000+ERID,Object.x,Object.y,Object.z Point Object 2000+ERID,Tx#,Ty#,Tz# EndFunction Function Move_E_Bullet(ERID) Dead=0 If Object Exist(2000+ERID)=0 then ExitFunction Dead Speed=Enemy_Bullet(ERID).Bullet_Speed If Speed=0 then Speed=1 For i = 1 to Speed If Enemy_Bullet(ERID).Bullet_Speed>0 Then Move Object 2000+ERID,1 Enemy_Bullet(ERID).Bullet_Range=Enemy_Bullet(ERID).Bullet_Range-1 If Enemy_Bullet(ERID).Bullet_Range=0 Enemy_Bullet(ERID).Bullet_Speed=0 scale=Enemy_Bullet(ERID).Bullet_Area/Object Size(2000+ERID)*100 Enemy_Bullet(ERID).Bullet_Damage=Enemy_Bullet(ERID).Bullet_Damage*3 Scale Object 2000+ERID,scale,scale,scale Color Object 2000+ERID,Rgb(255,0,0) Ghost Object On 2000+ERID Endif HitEnemy=Object Collision(2000+ERID,1) If HitEnemy armr=Rnd(Robot.Armor) If armr>Enemy_Bullet(ERID).Bullet_Damage Then armr=Enemy_Bullet(ERID).Bullet_Damage Robot.Health=Robot.Health-(Enemy_Bullet(ERID).Bullet_Damage-armr) If Robot.Health<1 Then Dead=1 Delete Object 2000+ERID ExitFunction Dead Endif If Enemy_Bullet(ERID).Bullet_Range<-10 Delete Object 2000+ERID ExitFunction Dead Endif Next i EndFunction Dead Function Make_Road() If Object Exist(501) Then Delete Object 501 If Bitmap Exist(1) Then Delete Bitmap 1 Create Bitmap 1,300,300 Set Current Bitmap 1 Ink RGB(128,128,128),0 Box 50,0,249,299 Ink RGB(75,75,75),0 For i = 1 to 300 Dot rnd(200)+50,rnd(299) Next i Ink RGB(198,198,0),0 For i = 0 to 250 step 50 Box 148,i,152,i+30 Next i Get Image 501,0,0,299,299 Set Current Bitmap 0 Delete Bitmap 1 Make Object Plain 501,175,175 Texture Object 501,501 Pitch Object Down 501,90 EndFunction Function Make_X_Road() If Object Exist(502) Then Delete Object 502 If Bitmap Exist(1) Then Delete Bitmap 1 Create Bitmap 1,300,300 Set Current Bitmap 1 Ink RGB(128,128,128),0 Box 50,0,249,299 Box 0,50,299,249 Ink RGB(75,75,75),0 For i = 1 to 300 Dot rnd(200)+50,rnd(299) Next i Ink RGB(198,198,0),0 For i = 0 to 250 step 50 Box 148,i,152,i+30 Box i,148,i+30,152 Next i Get Image 502,0,0,299,299 Set Current Bitmap 0 Delete Bitmap 1 Make Object Plain 502,175,175 Texture Object 502,502 Pitch Object Down 502,90 EndFunction Function Move_Roads() Move Object Up 501,.65 Move Object Up 502,.65 Return_Object(501) If Object.z<60-174 Then Position Object 501,0,-8,60+174 Return_Object(502) If Object.z<60-174 Then Position Object 502,0,-8,60+174 EndFunction Function Make_Special(sx#,sz#) If Object Exist(600) Then ExitFunction Special=Rnd(5) If Rnd(90)>Robot.Health And Special<>4 Then Special=Rnd(5) Select Special Case 0 Make Object Cube 600,5 Color Object 600,RGB(0,255,0) Special$="Health" Endcase Case 1 Make Object Sphere 600,5 Color Object 600,RGB(255,128,0) Special$="Range" Endcase Case 2 Make Object Cone 600,5 Color Object 600,RGB(0,0,255) Special$="Armor" Endcase Case 3 Make Object Cylinder 600,5 Color Object 600,RGB(128,0,128) Roll Object Left 600,90 Fix Object Pivot 600 Special$="Damage" Endcase Case 4 If Mesh Exist(600) Then Delete Mesh 600 Make Mesh From Object 600,1 Make Object 600,600,0 Scale Object 600,50,50,50 Color Object 600,RGB(255,255,0) Delete Mesh 600 Special$="Repair" Endcase Case 5 Make Object Cone 600,3 If Mesh Exist(600) Then Delete Mesh 600 Make Mesh From Object 600,600 Add Limb 600,1,600 Delete Mesh 600 Rotate Limb 600,1,180,0,0 Offset Limb 600,1,0,2,0 Roll Object Right 600,90 Fix Object Pivot 600 Special$="Speed" Endcase EndSelect Turn Object Right 600,180 Ghost Object On 600 Set Object Cull 600,0 Position Object 600,sx#,0,sz# EndFunction Function Move_Special() If Object Exist(600)=0 then ExitFunction Move Object 600,.65 Ink rgb(255,255,255),0 Center Text Object Screen X(600),Object Screen Y(600),Special$ Set Object Collision On 1 If Object Collision(600,1) Delete Object 600 Select Special Case 0 Robot.Health=Robot.Health+20 Endcase Case 1 Robot.Range=Robot.Range+1 EndCase Case 2 Robot.Armor=Robot.Armor+1 EndCase Case 3 Robot.Damage=Robot.Damage+1 EndCase Case 4 If Robot.Health<100 Then Robot.Health=100 EndCase Case 5 Robot.Speed=Robot.Speed+1 Endcase EndSelect ExitFunction Endif Set Object Collision Off 1 If Object Screen Y(600)>Screen Height()+3 Then Delete Object 600 EndFunction Function Start_Menu() Robot.Color=Rgb(255,255,255) Make_Road() Position Object 501,0,0,60 Pitch Object Up 501,90 Make_Robot(901) Position Object 901,0,0,50 If Bitmap Exist(1) Then Delete Bitmap 1 Create Bitmap 1,150,100 Set Current Bitmap 1 Ink RGB(0,255,0),0 Box 0,0,149,149 Ink RGB(15,24,140),0 Center Text 74,49,"START" Get Image 902,0,0,149,99 Ink RGB(255,255,0),0 Box 0,0,149,149 Ink RGB(15,24,140),0 Center Text 74,49,"EXIT" Get Image 903,0,0,149,99 Ink RGB(255,255,255),0 Box 0,0,149,149,RGB(255,255,255),RGB(255,255,255),0,RGB(255,255,255) Ink RGB(0,0,0),0 Center Text 74,49,"COLOR" Get Image 904,0,0,149,99 Ink RGB(0,255,0),0 Box 0,0,149,149,RGB(0,255,0),RGB(0,255,0),0,RGB(0,255,0) Ink RGB(0,0,0),0 Center Text 74,49,"COLOR" Get Image 905,0,0,149,99 Ink RGB(0,0,255),0 Box 0,0,149,149,RGB(0,0,255),RGB(0,0,255),0,RGB(0,0,255) Ink RGB(0,0,0),0 Center Text 74,49,"COLOR" Get Image 906,0,0,149,99 Delete Bitmap 1 Set Current Bitmap 0 Return_Camera() If Object Exist(902) Then Delete Object 902 Make Object Sphere 902,5,20,20 Scale Object 902,-300,-100,-100 Texture Object 902,902 Pitch Object Down 902,180 Fix Object Pivot 902 Position Object 902,0,15,50 Point Object 902,Camera.x,Camera.y,Camera.z If Object Exist(903) Then Delete Object 903 Make Object Sphere 903,5,20,20 Scale Object 903,-300,-100,-100 Texture Object 903,903 Pitch Object Down 903,180 Fix Object Pivot 903 Position Object 903,0,-15,50 Point Object 903,Camera.x,Camera.y,Camera.z For i=1 to 3 Ob=903+i If Object Exist(Ob) then Delete Object i Make Object Sphere Ob,5,20,20 Scale Object Ob,-150,-100,-100 Texture Object Ob,Ob Pitch Object Down Ob,180 Fix Object Pivot Ob Position Object Ob,(i-2)*10,-7,50 Point Object Ob,Camera.x,Camera.y,Camera.z Next i Show Mouse Do po=Pick Object(MouseX(),MouseY(),901,906) Select po Case 0 If Flag<>0 For i = 902 to 906 Return_Object(i) If Object.z<50 Then Move Object i,Object.z-50 Next i YRotate Object 901,0 Flag=0 Endif Endcase Case 901 Turn Object Left 901,1 Flag=1 Endcase Case Default If Mouseclick()=1 Then Start=Do_Menu_Item(po) If Start=1 Then Exit Return_Object(po) If Object.z>48 Then Move Object po,5 Flag=1 Endcase EndSelect Sync Loop For i = 901 to 906 If Object Exist(i) Then Delete Object i Next i Endfunction Function Do_Menu_Item(OBID) strt=0 Select OBID Case 902 strt=1 Endcase Case 903 End Endcase Case 904,905,906 Robot.Color=Point(MouseX(),MouseY()) Color Object 901,Robot.Color Endcase EndSelect Endfunction strt Function Minimap(ObjectID,Color) Return_Object(ObjectID) Ink Color,0 Box (Object.x/5)+600,50-(Object.z/5),(Object.x/5)+602,52-(Object.z/5) EndFunction Function Return_Target(TargetID) Target.x=Object Position X(TargetID):Target.y=Object Position Y(TargetID):Target.z=Object Position Z(TargetID) EndFunction Function Return_Object(ObjectID) Object.x=Object Position X(ObjectID):Object.y=Object Position Y(ObjectID):Object.z=Object Position Z(ObjectID) EndFunction Function Return_AI() AI.x=Object Position X(2):AI.y=Object Position Y(2):AI.z=Object Position Z(2) EndFunction Function Return_Camera() Camera.x=Camera Position X():Camera.y=Camera Position Y():Camera.z=Camera Position Z() EndFunction