` Coding Challenge Entry ` Author: RiiDii (Patrick Lewis) ` 24 March 2005 Randomize Timer() Sync On Sync Rate 60 Autocam Off: Position Camera 500,7,20: Set Camera Range .1,3000 Type Coordinates x as Float y as Float z as Float EndType Global Object as Coordinates Global Target as Coordinates Global Camera as Coordinates Global AI as Coordinates Global Retical_Angle as Coordinates Global Camera_Angle as Coordinates Global Last_Bullet as DWORD Global Bullet_Count Global New_Bullet Global TargetNum New_Bullet=200 Position Mouse Screen Width()/2,Screen Height()/2 Make_Field() Make_Target(4) Make Object Box 1,5,10,5 Position Object 1,500,5,20 Hide Object 1 Set Object Collision to Boxes 1 Make Object Sphere 2,1,3,3 Set Object Collision Off 2 Set Object Collision To Boxes 2 Make Object Cylinder 3,1 Scale Object 3,20,500,20 Hide Object 2 Pitch Object Down 3,90 Fix Object Pivot 3 Make Mesh from Object 3,3 Delete Object 3 Make Object 3,3,0 Delete Mesh 3 Set Object Cull 3,0 Set Object Collision Off 3 Make Object Sphere 5,4 Pitch Object Down 5,90 Set Alpha Mapping On 5,30 Color Object 5,Rgb(255,0,0) Set Object Emissive 5,rgb(100,0,0) Fix Object Pivot 5 Disable Object zDepth 5 Make_Flash() Do Player() Bullet() If Rnd(100)=1 Then New_Target() Ink Rgb(255,255,255),0 Set Cursor 0,0 Print TargetNum Sync Loop Function Player() Turn Object Left 1,(LeftKey()-RightKey())*3 Move Object 1,(UpKey()-DownKey())*3 Return_Object(1) Position Object 1,Object.x,Get Ground Height(1,Object.x,Object.z)+5,Object.z Return_Object(1) Position Object 5,Object.x,Object.y,Object.z Set Object To Object Orientation 5,1 Retical_Angle.y=Retical_Angle.y+MouseMoveX()*.1 Retical_Angle.x=Retical_Angle.x-MouseMoveY()*.1 If Retical_Angle.y>45 then Retical_Angle.y=45 If Retical_Angle.y<-45 then Retical_Angle.y=-45 If Retical_Angle.x>20 then Retical_Angle.x=20 If Retical_Angle.x<-20 then Retical_Angle.x=-20 Turn Object Right 5,Retical_Angle.y Pitch Object Up 5,Retical_Angle.x Move Object 5,200 PC=Object Collision(1,0) Set Cursor 0,0:Print PC Select PC Case 901 Do Return_Object(1) Position Object 1,Object.x,Object.y,Object.z+.5 If Object Collision(1,901)=0 Then Exit Loop EndCase Case 902 Do Return_Object(1) Position Object 1,Object.x+.5,Object.y,Object.z If Object Collision(1,902)=0 Then Exit Loop EndCase Case 903 Do Return_Object(1) Position Object 1,Object.x-.5,Object.y,Object.z If Object Collision(1,903)=0 Then Exit Loop EndCase Case 904 Do Return_Object(1) Position Object 1,Object.x,Object.y,Object.z-.5 If Object Collision(1,904)=0 Then Exit Loop EndCase Case Default If PC>600 and PC<900 Do Return_Object(1) Return_Target(PC) Position Object 2,Object.x,Object.y,Object.z Point Object 2,Target.x,Target.y,Target.z Move Object 2,-.5 Return_AI() Position Object 1,AI.x,AI.y,AI.z PC=Object Collision(1,0) If PC<600 or PC>900 then Exit Loop Endif EndCase EndSelect Return_Object(1) Position Object 3,Object.x,Object.y+1,Object.z Set Object To Object Orientation 3,1 Move Object Right 3,1 Return_Target(5) Point Object 3,Target.x,Target.y,Target.z Position Camera Object.x,Object.y+2,Object.z Move Object 1,10 Return_Object(1) Point Camera Object.x,Object.y,Object.z Move Object 1,-10 Hide Object 6 If MouseClick()=1 then Make_Bullet() EndFunction Function Make_Bullet() If Timer()-Last_Bullet<200 then ExitFunction Last_Bullet=Timer() If Object Exist(New_Bullet) then Delete Object New_bullet Make Object Sphere New_Bullet,.3,1,1 Scale Object New_Bullet,100,100,200 Set Object Collision To Boxes New_Bullet Return_Object(3) Return_Target(5) Position Object New_Bullet,Object.x,Object.y,Object.z Point Object New_Bullet,Target.x,Target.y,Target.z Return_Object(New_Bullet) Position Object 6,Object.x,Object.y,Object.z Set Object To Object Orientation 6,New_Bullet Show Object 6 Move Object 6,2.6 Roll Object Right 6,rnd(359) New_Bullet=New_Bullet+1 If New_Bullet>248 Then New_Bullet=200 EndFunction Function Bullet() Bullet_Count=0 For i = 200 to 249 If Object Exist(i) Bullet_Count=Bullet_Count+1 For j = 1 to 20 If Abs(New_Bullet-i)<4 Ink rgb(50+j*3,50+j*3,50+j*3),0 Dot Object Screen x(i),Object Screen y(i)+4 Endif Move Object i,2 Return_Object(i) BC=Object Collision(i,0) If BC>10 If BC>1000 Then Delete Object BC Delete Object i Exit Else If Object.x<-100 or Object.x>1100 or Object.z<-100 or Object.z>1100 Or Object.y<Get Ground Height(1,Object.x,Object.z) Delete Object i Exit Endif Endif Next j Endif Next i Endfunction Function Make_Target(ObjectID) Make Object Box ObjectID,5,10,5 Make Mesh From Object ObjectID,ObjectID Delete Object ObjectID Make Object Sphere ObjectID,.01,1,1 Add Limb ObjectID,1,ObjectID OffSet Limb ObjectID,1,0,5,0 Delete Mesh ObjectID If Bitmap Exist(1) Then Delete Bitmap 1 Create Bitmap 1,128,256 Set Current Bitmap 1 Ink rgb(255,255,255),0 Box 0,0,127,256 Color$="Red" For i# =0.0 to 60.0 step .5 If i#/10.0=Int(i#/10.0) If Color$="Red" Ink 0,0 Color$="Black" Else ink rgb(255,0,0),0 Color$="Red" Endif Endif Circle 63,63,i# Next i Get Image ObjectID,0,0,127,255,1 Texture Limb ObjectID,1,ObjectID Set Current Bitmap 0 EndFunction Function Make_Field() If Matrix Exist(1) Then Delete Matrix 1 Make Matrix 1,1000,1000,100,100 Randomize Matrix 1,8 If Bitmap Exist(1) Then Delete Bitmap 1 Create Bitmap 1,128,128 Set Current Bitmap 1 Ink RGB(0,128,0),0 Box 0,0,127,127 For i=1 to 200 Dot rnd(127),rnd(127),Rgb(10,Rnd(255),10) Next i Get Image 999,0,0,127,127 Prepare Matrix Texture 1,999,1,1 Update Matrix 1 Make Object Box 901,1000,30,2 Make Object Box 902,1000,30,2 Make Object Box 903,1000,30,2 Make Object Box 904,1000,30,2 Position Object 901,500,10,0 Position Object 902,0,10,500 Turn Object Left 902,90 Position Object 903,1000,10,500 Position Object 904,500,10,1000 Turn Object Right 903,90 `Turn Object Left 904,90 Make Object Sphere 601,10,8,8 Make Object Cylinder 602,5 Scale Object 602,30,200,30 Make Mesh From Object 602,602 Add Limb 601,1,602 Delete Object 602 Delete Mesh 602 Offset Limb 601,1,0,2.5,0 Offset Limb 601,0,0,12,0 Texture Limb 601,0,999 Color Limb 601,1,RGB(128,64,64) Make Object Sphere 602,8,8,8 Color Object 602,RGB(109,103,78) For i = 1 to rnd(50)+rnd(50)+rnd(50)+rnd(50)+rnd(50)+rnd(50)+rnd(50) cln=rnd(1)+1 Clone Object 602+i,600+cln x=rnd(980)+10:z=rnd(980)+10 Position Object 602+i,x,Get Ground Height(1,x,z),z Set Object Collision To Boxes 602+i Next i x=rnd(980)+10:z=rnd(980)+10 Position Object 601,x,Get Ground Height(1,x,z),z Set Object Collision To Boxes 601 x=rnd(980)+10:z=rnd(980)+10 Position Object 602,x,Get Ground Height(1,x,z),z Set Object Collision To Boxes 602 EndFunction Function Make_Flash() Make Object Cone 6,.3 Pitch Object Up 6,90 Fix Object Pivot 6 Make Mesh from Object 6,6 Delete Object 6 If Bitmap Exist(1) Then Delete Bitmap 1 Create Bitmap 1,128,128 Set Current Bitmap 1 Ink 0,0 Box 0,0,127,127 Ink Rgb(255,0,0),0 x=0 Do x=x+rnd(5)+1 if x>126 Then Exit Line x,0,x,127 Loop Get Image 6,0,0,127,127 Make Object 6,6,6 Delete Mesh 6 Set Current Bitmap 0 Delete Bitmap 1 Set Object Cull 6,0 Set Object Collision Off 6 Set Alpha Mapping On 6,80 Set Object Emissive 6,Rgb(200,100,100) Hide Object 6 EndFunction Function New_Target() For i = 1001 to 1020 If Object Exist(i)=0 Then Exit Next i If i>1020 Then ExitFunction TargetNum = i Clone Object i,4 Return_Object(1) Do r#=Rnd(200.0)+50.0 x#=sin(Rnd(359.0))*r#+Object.x z#=cos(Rnd(359.0))*r#+Object.z Position Object i,x#,0,z# TC=Object Collision(i,0) if x#>10 and x#<990 and z#>10 and z#<990 and TC=0 Then Exit Loop Turn Object Right i,Rnd(360) `Pitch Object Down i,90 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 Function Make_AI() If Object Exist(2) Then Delete Object 2 Make Object Sphere 2,1,6,6 EndFunction