This is the code for my 20 line space shooter called astro-zoids.
the aim of the game is to be the last one standing
The controls for player one are arrowkeys to rotate and 0 ins for fire
The controls for player 2 are wasd and space for fire.
to shoot the other player you have to look directly at their ship(a circle crosshair should come up) aand press fire.
You can only fire when your weapon is charged.
If you hit an asteroid you die.
If you are shot you die.
If you die when you have no lives left, you lose
The controls system is a bit off because off the free flight bugs, so when patch 5 arrrives i will make a better one.
The game requires these two images saved in the same folder as the .dba
and here is the code:
rem ASTRO-ZOIDS
rem made-by Daniel Huggins (darkfluff)
make camera 3 ; set camera view 3,0,0,640,240 ; delete camera 3 ; dim ang#(3,2) ; dim lives(2)
make camera 2 ; set camera view 2,0,240,640,480 ; make camera 1 ; set camera view 1,0,0,640,240 ; sync on
position camera 1,300,0,0 ; position camera 2,-300,0,0 ; ink RGB(255,0,0),0
make object sphere 7,2000 ; load image "stars.bmp",1 ; texture object 7,1 ; scale object 7,-100,100,100 ; set object light 7,0
for t = 1 to 2 ;make object cube t,5 ; SET OBJECT COLliSION TO SPHERES t ; make object cube t+2,10 ; hide object t+2
position camera p,p-1.5*400,0,0 ; ; color object t,4278190335 ; next t ; dim a#(5,2) ; dim inp(10,2) ; inp(1,1) = 200 ; inp(2,1) = 205 ; inp(3,1) = 208 ; inp(4,1) = 203 ; inp(5,1) = 82 ; inp(6,1) = 17 ; inp(7,1) = 32 ; inp(8,1) = 31 ; inp(9,1) = 30 ; inp(10,1) = 57
load image "crater.bmp",2 ; for t = 20 to 70 ; make object sphere t,t ; texture object t,2 ; SET OBJECT COLliSION TO SPHERES t ;
position object t,rnd(300)-150,rnd(300)-150,rnd(300)-150 ; next t
a#(1,1) = 200 ; a#(1,2) = -200 ; do ; for t = 1 to 10 ; inp(t,2)=keystate(inp(t,1)) ; next t ; for p = 1 to 2
ang#(1,p)= ang#(1,p) + inp(((p-1)*5)+3,2) * 3 - inp(((p-1)*5)+1,2) * 3 ; ang#(2,p) = ang#(2,p) + inp(((p-1)*5)+2,2) *3 - inp(((p-1)*5)+4,2) * 3; rotate camera p,ang#(1,p),ang#(2,p),0 ; move camera p,1 ; a#(1,p) = camera position x(p) ; a#(2,p) = camera position y(p) ; a#(3,p) = camera position z(p)
if sqrt(a#(2,p)^2 + a#(3,p)^2 + a#(1,p)^2) > 350 then position camera p,a#(1,p)*-1,a#(2,p)*-1,a#(3,p)*-1
if (lives(p)) = -4 then center text 320,240,"player " + str$(-p+3) + " wins" ; sync ; wait 10000 ; end
for t = 20 to 70 ; position object p,a#(1,p),a#(2,p),a#(3,p) ; if object collision(p,t)=1 then die(p) ; lives(p) = lives(p) - 1
next t ; position object p+2,a#(1,p),a#(2,p),a#(3,p) ; rotate object p+2,ang#(1,p),ang#(2,p),0 ; for dist = 1 to 40 ; move object p+2,10
if object collision(p+2,(p-1)*-1+2) and rockhit = 0 then circle 320,(p - 0.5) * 240,10 ; if a#(5,p) = 1 then lives(-p+3) = lives(-p+3) - 1 ; die(-p+3)
for t = 20 to 70 ; if object collision(p+2,t) = 1 then rockhit = 1
next t ; next dist ; enemyhit = 0 ; rockhit = 0 ; a#(4,P) = a#(4,P) + 1 ; a#(5,p) = 0 ; if a#(4,p) > 30 then text 570,(p*240 - 240),"charged" ; if inp(p*5,2) = 1 then a#(4,p) =0 ; a#(5,p) = 1
next p; text 0,0,"player 1 lives: " + str$(lives(1) + 3) ; text 0,240,"player 2 lives: " + str$(lives(2) + 3)
sync ; loop
function die(p) ; position camera p,(p-1.5)*600,0,0 ; point camera p,0,0,0 ; endfunction
Life is a terminal disease.
You never survive it.