`DARK DRAGON'S DEATHMATCH ARENA
`AUG.8th 07
`===========================================
`INSTUCTIONS=================================
`Move: left,right,up and downkeys
`Fire: Space
`Team Colors:0=red  1=green 2=black 3=blue
`=================================================
`MAINMENU================================
do
if button(200,200,"New Game") then GOSUB _PICK_OPTIONS
loop
`submenus=====================================
_PICK_OPTIONS:
pteamcolor=green
do
set cursor 300,0
Print "Player color = ";pteamcolor
set cursor 300,30
Print "Enemy color = ";eteamcolor
if button(50,50,"Toggle color")
pteamcolor=pteamcolor+1
wait 50
cls
endif
if pteamcolor=4
pteamcolor=0
endif
if button(70,70,"Toggle enemy color")
eteamcolor=eteamcolor+1
wait 50
cls
endif
if eteamcolor=4
eteamcolor=0
endif
sync
if button(130,130,"FIGHT!!!") and eteamcolor=pteamcolor
TEXT 150,300,"ERROR:YOU CAN'T HAVE THE SAME TEAM COLOR AS YOUR OPPONENT!!!"
wait 2000
goto _PICK_OPTIONS
endif
 
if button(130,130,"FIGHT!!!")
Gosub _GAME
endif
if button(170,170,"Toggle camera")=1
cls
camera=camera+1
if camera=2 then camera=0
endif
if button(100,90,"+ ally") then cls:ally=ally+1
if button(150,100,"- ally") then cls:ally=ally-1
if ally=2 then ally=1
set cursor 320,60
Print "Allies =";ally
if button(20,90,"+ enemies") then cls:enemies=enemies+1
if button(40,110,"- enemies") then cls:enimies=enemies-1
set cursor 340,90
Print "Enemies = ";enemies
set cursor 380,100
if camera=0 then print "Camera View = Top down(reccomended) "
if camera=1 then print "Camera View = Third Person "
sync
loop
`=============================================
 
`GAME=====================================
_GAME:
obj2=enemy
enemy1health=50
health=50
`Translate camera views
if camera=0 then topdown=1
if camera=1 then thirdperson=1
MAKE OBJECT CUBE 1,90
make object cube 2,90
if ally=1
MAKE OBJECT CUBE 3,90
endif
make matrix 1,5000,5000,45,45
set matrix wireframe on 1
x#=4000
z#=4000
e1z=3000
e1x=3000
f1x=2000
f1z=2000
e2z=3000
e2x=5000
f2x=7000
f2z=5000
if pteamcolor=0
color object 1,RGB(250,0,0)
color object 3,RGB(250,0,0)
endif
if pteamcolor=1
color object 1,RGB(0,250,0)
color object 3,RGB(0,250,0)
endif
if pteamcolor=2
color object 1,RGB(0,0,0)
color object 3,RGB(0,0,0)
endif
if pteamcolor=3
color object 1,RGB(0,0,250)
color object 3,RGB(0,0,250)
endif
if eteamcolor=0
color object 2,RGB(250,0,0)
endif
if eteamcolor=1
color object 2,RGB(0,250,0)
endif
if eteamcolor=2
color object 2,RGB(0,0,0)
endif
if eteamcolor=3
color object 2,RGB(0,0,250)
endif
 
 
 
y#=get ground height(1,x#,z#)
randomize matrix 1,30
sync on
DO
if downkey()=1 then x#=newxvalue(x#,a#,-20) : z#=newzvalue(z#,a#,-20)
if upkey()=1 then x#=newxvalue(x#,a#,20) : z#=newzvalue(z#,a#,20)
if leftkey()=1 then a#=wrapvalue(a#-5.0)
if rightkey()=1 then a#=wrapvalue(a#+5.0)
if spacekey()=1
if object exist(600)=1 then delete object 600
if guntired=0
make object cylinder 600,30
yrotate object 600,a#
position object 600,x#,y#,z#
fired=1
endif
endif
if fired=1
move object 600,30
endif
 
y#=get ground height(1,x#,z#)
if thirdperson=1
cx#=newxvalue(x#,wrapvalue(a#+180),+480)
cz#=newzvalue(z#,wrapvalue(a#+180),+480)
cy#=get ground height(1,cx#,cz#)+200.0
endif
if topdown=1
cx#=newxvalue(x#,wrapvalue(a#+180),+180)
cz#=newzvalue(z#,wrapvalue(a#+180),+180)
cy#=get ground height(1,cx#,cz#)+2000.0
endif
position camera cx#,cy#,cz#
yrotate object 1,a#
position object 1,x#,y#+50,z#
if e1posed=0
position object 2,e1x,y#+50,e1z
e1posed=1
endif
if f1posed=0
if object exist(3)=1 then position object 3,f1x,y#+50,f1z
f1posed=1
endif
point camera x#,y#,z#
sync
`Check for collisions
if object exist(2)=1 and object exist(600)=1
if object collision(600,2)
enemy1health=enemy1health-5
endif
endif
if object exist(1)=1 and object exist(601)=1
if object collision(601,1)
health=health-5
delete object 601
endif
endif
if object collision(1,2)
move object 2,-10
endif
 
`......and check for dead people....
if health=0
hide object 1
`get respawn coordinates...
x#=rnd(5000)
z#=rnd(5000)
sleep 5
`restore health and position bot at respawn point.
position object 1,x#,y#+50,z#
show object 1
health=50
endif
if enemy1health=<1
hide object 2
kills=kills+1
`get respawn coordinates...
e1x=rnd(5000)
e1z=rnd(5000)
`restore health and position bot at respawn point.
position object 2,e1x,y#,e1z
show object 2
enemy1health=100
endif
`AI==============================
`Simple "Follow the leader" bot
point object 2,x#,y#+50,z#
move object 2,10
` randomly fire off bullet(Some RNDs to Prevent Perfect Aim)
firex=x#+Rnd(90)
firez=z#-Rnd(90)
if Rnd(500)=<10
if object exist(601)=1 then delete object 601
make object cylinder 601,30
position object 601,object position x(2),y#+50,object position z(2)
point object 601,firex,y#+50,firez
endif
`Simple "Follow the leader" bot
point object 3,object position x(2),y#+50,object position z(2)
move object 3,10
` randomly fire off bullet(Some RNDs to Prevent Perfect Aim)
ffirex=object position x(2)+Rnd(90)
ffirez=object position z(2)-Rnd(90)
if Rnd(500)=<10
if object exist(602)=1 then delete object 602
make object cylinder 602,30
position object 602,object position x(3),y#+50,object position z(3)
point object 602,ffirex,y#+50,ffirez
endif
if object exist(602)=1
point object 602,ffirex,y#+50,ffirez
move object 602,30
endif
draw to front
`Display Info and Quit Button
if button(350,10,"Quit")=1 then end
set cursor 25,0
Print "Player Health = ";health
set cursor 40,20
Print "Enemy 1 Health = ";enemy1health
set cursor 70,50
Print "ally 1 Health = ";allyhealth
 
LOOP
 
 
`=========================================
 
 
 
 
 
`FUNCTIONS====================================
function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(0,255,0),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed
 
 
`========================================================