REM This was made by Jo in 2001.

dim height(50)
dim scroll(50)
scroll=640
for z=1 to 50
scroll(z)=ran(640+300)
height(z)=ran(512)
height(z)=height(z)
next z

score=0
game=77
zz=640
hits=0
gosub title
clear window
gosub instructions
close window
beam=640
open window 640,512
window origin "lb"
a=640
dam=0
b=ran(512)
label loop
gosub buffer
gosub back
gosub blast
blast=0
gosub beam
gosub keys
gosub stars
gosub draw
gosub flame
speed=0
gosub fire
gosub asteroids
gosub damage
goto loop

label title
open window 640,512
window origin "lb"
99
wait 0.03
clear window
text (zz),400,"ThE EARTh IS IN DANGER! ASTEROIDS WILL POUND ThE SURFACE UNLESS YOU DESTROY ThEM BEFORE ThEY REACH US. SPACEDUDE, YOU ARE OUR LAST HOPE!" 
setrgb 1,250,250,250
text 120,256,"         -S P A C E D U D E-"
setrgb 1,200,0,0
text 100,136,"Warning: This game contains flashing lights."
setrgb 1,200,200,200
text 100,106,"     ThIS LITTLE GAME WAS MADE BY JO."
zz=zz-2
if zz<-1400 zz=640
if peek("port1")=0 then
goto 99
endif
return

label instructions
wait 0.03
clear window
text 60,276,"         USE ThE D-PAD TO MOVE SPACEDUDE."
text 60,256,"     DON'T FALL OF THE BOTTOM OF THE SCREEN"
text 60,236,"USE X TO ShOOT ThE ASTEROIDS BEFORE ThEY hIT EARTh."
text 30,206,"PRESS X FOR EASY, SQUARE FOR HARD AND TRIANGLE FOR EXTREME"

wait 0.2
if peek("port1")=16384 then
game=1
endif
if peek("port1")=32768 then
game=2
endif
if peek("port1")=4096 then
game=3
endif
if game=77 then
goto instructions
endif
return

label back
if blast=0 then
setrgb 1,0,0,55
setrgb 2,0,0,0
setrgb 3,0,0,100
gtriangle 0,0 to 640,510 to 0,510
setrgb 3,0,0,0
gtriangle 0,0 to 640,0 to 640,510
endif
return


label buffer
setdrawbuf dw
dw=1-dw
setdispbuf dw
clear window
return

label blast

if blast=1 then
setrgb 1,255,255,255
setrgb 2,0,0,0
setrgb 3,200,200,200
gtriangle 0,0 to 640,510 to 0,510
setrgb 3,0,0,0
gtriangle 0,0 to 640,0 to 640,510
endif
if blast=2 then
setrgb 1,255,255,0
setrgb 2,0,0,0
setrgb 3,200,200,0
gtriangle 0,0 to 640,510 to 0,510
setrgb 3,0,0,0
gtriangle 0,0 to 640,0 to 640,510
endif

return


label draw
setrgb 1,50,50,50
fill rectangle (fx+43),(fy+320) to (fx+58),(fy+305)
setrgb 1,150,150,150
fill rectangle (fx+48),(fy+320) to (fx+62),(fy+300)
setrgb 1,100,100,100
fill rectangle (fx+50),(fy+320) to (fx+60),(fy+330)
fill rectangle (fx+46),(fy+318) to (fx+52),(fy+310)
fill rectangle (fx+46),(fy+310) to (fx+60),(fy+304)
fill rectangle (fx+54),(fy+300) to (fx+62),(fy+290)
setrgb 1,150,150,150
fill rectangle (fx+48),(fy+300) to (fx+57),(fy+289)
setrgb 1,85,85,85
fill rectangle (fx+60),(fy+305) to (fx+65),(fy+310) 
setrgb 1,50,50,50
fill rectangle (fx+60),(fy+329) to (fx+55),(fy+324)
setrgb 1,255,250,255
fill rectangle (fx+60),(fy+310) to (fx+70),(fy+313)
return


label keys
c=peek("port1")
if (and(c,128)<>0) fx=fx-10
if (and(c,128)<>0) speed=0
if (and(c,16)<>0) fy=fy+10
if (and(c,16)<>0) speed=1
if (and(c,64)<>0) fy=fy-5
if (and(c,64)<>0) speed=0
if (and(c,64)<>0) down=20
if (and(c,32)<>0) fx=fx+10
if (and(c,32)<>0) speed=1
if (and(c,16384)<>0) fire=1
fy=fy-down/2
down=down+0.2
if speed=1 down=3
if fy<-440 goto loser
return

label fire
if fire=1 and beam>0 then
if game=1 then
beam=beam-1
endif
if game=2 then
beam=beam-1
endif
if game=3 then
beam=beam-0.5
endif
setrgb 1,255,0,5
fill circle (fx+70),(fy+313),5
line (fx+70),(fy+313) to 640,(fy+313)
REM ThIS IS ThE ShOOTIN' STUFF
if (fy+313)<(b+20) and (fy+313)>(b-20) and fx<a then
gosub boom 
endif
endif
fire=0
return

label flame
setrgb 1,255,0,0
setrgb 2,255,255,0
setrgb 3,255,0,0
if speed=1 then
gtriangle (fx+43),(fy+305) to (fx+50),(fy+305) to (fx+45),(fy+290)
endif
return

label asteroids
if a=0 then
b=ran(512)
a=640
blast=1
score=score-100
if game=3 then
dam=dam+2
endif
if game=1 then
dam=dam+10
endif
if game=2 then
dam=dam+5
endif
endif
if a=-5 then
b=ran(512)
a=640
blast=2
score=score+50
endif
setrgb 1,65,55,50
b=b
fill circle (a),(b),20
if game=1 then
a=a-5
endif
if game=2 then
a=a-10
endif
if game=3 then
a=a-20
endif
return

label damage
setrgb 1,250,250,250
line 0,30 to 640,30
text 170,10,"E A R T h  D A M A G E: "+str$(dam)+"%"
line 0,15 to 160,15
line 640,15 to 460,15 
if dam>99 then
gosub loser
endif
if hits=50 then
gosub winner
endif
return

label beam
if beam>0 then
setrgb 1,255,255,0
setrgb 2,255,255,0
setrgb 3,255,0,0
gtriangle 0,509 to 0,495 to (beam),509
setrgb 1,255,255,0
setrgb 2,255,0,0
setrgb 3,255,0,0
gtriangle 0,495 to (beam),509 to (beam),495
endif
if beam<1 then
setrgb 1,255,255,255
text 130,500,"YOU'VE USED ALL YA' BULLETS YOU MUPPET!"
text 130,480,"  NO ONE LIKES TRIGGER HAPPY IDIOTS!"
endif
return

label stars
setrgb 1,ran(255),ran(255),ran(250)
for z=1 to 50
height(z)=height(z)
fill circle 360+(scroll(z)),height(z),ran(5)
scroll(z)=scroll(z)-2
if scroll(z)<-370 then
scroll(z)=640
height(z)=ran(512)
endif
next z
return


label boom
a=-5
hits=hits+1
return

label loser
close window
open window 640,512
setrgb 1,255,255,255
text 110,256,"ThE EARTh IS NO MORE, AND IT IS YOUR FAULT!"
text 110,236,"             Y O U  L O S E !"
20
goto 20

label winner
close window
open window 640,512
setrgb 1,255,255,255
text 70,256,"  HEY, SPAEDUDE! YOU DID IT! ThE EARTh IS SAVED!"
text 70,236,"                -Y O U  W I N !-"
text 120,186,"     YOUR SCORE WAS: "+str$(score)+" points."

setrgb 1,255,0,0
text 70,106,"check out yabasic.co.uk for more games and demos."
30
goto 30









