open window 640,512
setrgb 0,0,0,0
clear window
level=1
lives=5
dim cosines(360) 
dim sines(360) 
for angle=0 to 360 
cosines(angle)=cos(angle*(pi/180)) 
sines(angle)=sin(angle*(pi/180)) 
next angle
gosub progresslevel
score=0
repeat
con=peek("port1")
setdrawbuf dw
dw=1-dw
setdispbuf dw 
setrgb 0,0,0,0
clear window
setrgb 1,255,255,0
text 235,150,"B U S T  O U T!!"
setrgb 1,255,0,0
text 270,200,"Coded by"
text 285,300,"A K A"
setrgb 1,0,255,0
text 225,250,"Bradley Beardsworth"
text 235,350,"* * DEMONEYE * *" 
setrgb 1,255,255,255
text 230,450,"<press X to play>"
until(and(con,16384)>0)

label setup
x=400 : y=300
batx=320
bspeed=5
dx=int(ran(5))+bspeed
dy=int(ran(2))+bspeed
r1=int(ran(10))
if r1>5 dx=-dx
r2=int(ran(10))
if r2>5 dy=-dy
if level=1 maxblox=16
if level=2 maxblox=19
if level=3 maxblox=5
if level=4 maxblox=20
if level=5 maxblox=16
if level=6 maxblox=9
if level=7 maxblox=14
if level=8 maxblox=21
maxlevel=9


label mainloop
setdrawbuf dw
dw=1-dw
setdispbuf dw
setrgb 0,0,0,0
clear window
gosub setupscreen
gosub blox
gosub movebat
gosub moveball
gosub col
if lives=0 goto death
if maxblox=0 goto win
goto mainloop


label setupscreen
setrgb 1,200,200,200
line 30,30 to 30,512
line 30,30 to 500,30
setrgb 1,200,80,0
setrgb 2,0,0,0
setrgb 3,0,0,0
gtriangle 31,512 to 31,450 to 499,450
setrgb 2,200,100,0
gtriangle 31,512 to 499,512 to 499,450
setrgb 1,255,255,255
setrgb 2,40,40,40
setrgb 3,40,40,40
r=7 : s=(200-r)/8
if lives>4 then
ang=0 
repeat 
xo1=cosines(ang)*r:yo1=sines(ang)*r
xo2=cosines(ang+s)*r:yo2=sines(ang+s)*r
gtriangle 520,90 to 520+xo1,90+yo1 to 520+xo2,90+yo2 
gtriangle 520,90 to 520-xo1,90+yo1 to 520-xo2,90+yo2 
gtriangle 520,90 to 520-xo1,90-yo1 to 520-xo2,90-yo2 
gtriangle 520,90 to 520+xo1,90-yo1 to 520+xo2,90-yo2 
ang=ang+s
until (ang>90) 
fi
if lives>3 then
ang=0 
repeat 
xo1=cosines(ang)*r:yo1=sines(ang)*r
xo2=cosines(ang+s)*r:yo2=sines(ang+s)*r
gtriangle 540,90 to 540+xo1,90+yo1 to 540+xo2,90+yo2 
gtriangle 540,90 to 540-xo1,90+yo1 to 540-xo2,90+yo2 
gtriangle 540,90 to 540-xo1,90-yo1 to 540-xo2,90-yo2 
gtriangle 540,90 to 540+xo1,90-yo1 to 540+xo2,90-yo2 
ang=ang+s
until (ang>90) 
fi
if lives>2 then
ang=0 
repeat 
xo1=cosines(ang)*r:yo1=sines(ang)*r
xo2=cosines(ang+s)*r:yo2=sines(ang+s)*r
gtriangle 560,90 to 560+xo1,90+yo1 to 560+xo2,90+yo2 
gtriangle 560,90 to 560-xo1,90+yo1 to 560-xo2,90+yo2 
gtriangle 560,90 to 560-xo1,90-yo1 to 560-xo2,90-yo2 
gtriangle 560,90 to 560+xo1,90-yo1 to 560+xo2,90-yo2 
ang=ang+s
until (ang>90) 
fi
if lives>1 then
ang=0 
repeat 
xo1=cosines(ang)*r:yo1=sines(ang)*r
xo2=cosines(ang+s)*r:yo2=sines(ang+s)*r
gtriangle 580,90 to 580+xo1,90+yo1 to 580+xo2,90+yo2 
gtriangle 580,90 to 580-xo1,90+yo1 to 580-xo2,90+yo2 
gtriangle 580,90 to 580-xo1,90-yo1 to 580-xo2,90-yo2 
gtriangle 580,90 to 580+xo1,90-yo1 to 580+xo2,90-yo2 
ang=ang+s
until (ang>90) 
fi
if lives>0 then
ang=0 
repeat 
xo1=cosines(ang)*r:yo1=sines(ang)*r
xo2=cosines(ang+s)*r:yo2=sines(ang+s)*r
gtriangle 600,90 to 600+xo1,90+yo1 to 600+xo2,90+yo2 
gtriangle 600,90 to 600-xo1,90+yo1 to 600-xo2,90+yo2 
gtriangle 600,90 to 600-xo1,90-yo1 to 600-xo2,90-yo2 
gtriangle 600,90 to 600+xo1,90-yo1 to 600+xo2,90-yo2 
ang=ang+s
until (ang>90) 
fi
setrgb 1,255,255,0
text 530,180,str$(score)
setrgb 1,255,255,0
text 530,260,str$(level)
setrgb 1,255,255,0
text 530,350,str$(maxblox)
setrgb 1,255,255,255
text 510,70,"L I V E S:"
setrgb 1,255,255,255
line 500,120 to 630,120
text 510,150,"S C O R E:"
setrgb 1,255,255,255
line 500,200 to 630,200
text 510,230,"L E V E L:"
setrgb 1,255,255,255
line 500,290 to 630,290
text 510,310,"B L O C K S"
text 520,330,"L E F T:"
setrgb 1,255,255,255
line 500,370 to 630,370
line 500,30 to 500,512
line 630,30 to 630,512
line 500,30 to 630,30
return


label blox
sqy=70
for by=1 to 3
sqx=110
for bx=1 to 7
if blocks(bx,by)=0 goto breakit
 if blocks(bx,by)=1 then
 setrgb 1,255,0,0
 setrgb 2,100,0,0
 setrgb 3,100,0,0
 gtriangle sqx,sqy to sqx+10,sqy+10 to sqx-10,sqy+10
 gtriangle sqx,sqy to sqx-10,sqy-10 to sqx-10,sqy+10
 gtriangle sqx,sqy to sqx-10,sqy-10 to sqx+10,sqy-10
 gtriangle sqx,sqy to sqx+10,sqy+10 to sqx+10,sqy-10
 setrgb 1,255,100,50
 line sqx-10,sqy-10 to sqx+10,sqy-10
 line sqx-10,sqy-10 to sqx-10,sqy+10
 fi
if blocks(bx,by)=2 then
 setrgb 1,0,0,255
 setrgb 2,0,0,100
 setrgb 3,0,0,100
 gtriangle sqx,sqy to sqx+10,sqy+10 to sqx-10,sqy+10
 gtriangle sqx,sqy to sqx-10,sqy-10 to sqx-10,sqy+10
 gtriangle sqx,sqy to sqx-10,sqy-10 to sqx+10,sqy-10
 gtriangle sqx,sqy to sqx+10,sqy+10 to sqx+10,sqy-10
 setrgb 1,100,100,255
 line sqx-10,sqy-10 to sqx+10,sqy-10
 line sqx-10,sqy-10 to sqx-10,sqy+10 
fi
if blocks(bx,by)=3 then
 setrgb 1,0,255,0
 setrgb 2,0,100,0
 setrgb 3,0,100,0
 gtriangle sqx,sqy to sqx+10,sqy+10 to sqx-10,sqy+10
 gtriangle sqx,sqy to sqx-10,sqy-10 to sqx-10,sqy+10
 gtriangle sqx,sqy to sqx-10,sqy-10 to sqx+10,sqy-10
 gtriangle sqx,sqy to sqx+10,sqy+10 to sqx+10,sqy-10
 setrgb 1,100,255,100
 line sqx-10,sqy-10 to sqx+10,sqy-10
 line sqx-10,sqy-10 to sqx-10,sqy+10 
fi
if blocks(bx,by)=10 then
 setrgb 1,255,255,0
 fill rect sqx-10,sqy-10 to sqx+10,sqy+10
 setrgb 1,100,255,100
 line sqx-10,sqy-10 to sqx+10,sqy-10
 line sqx-10,sqy-10 to sqx-10,sqy+10
 setrgb 1,0,0,0
 text sqx-5,sqy+5,"L" 
fi
if blocks(bx,by)=20 then
 setrgb 1,155,155,155
 fill rect sqx-10,sqy-10 to sqx+10,sqy+10
 setrgb 1,200,200,200
 line sqx-10,sqy-10 to sqx+10,sqy-10
 line sqx-10,sqy-10 to sqx-10,sqy+10
fi

if x<=sqx+10 and x>=sqx-10 and y<=sqy+10 and y>=sqy-10 then
if blocks(bx,by)<10 then
 blocks(bx,by)=blocks(bx,by)-1
 if blocks(bx,by)=0 maxblox=maxblox-1
 score=score+10
fi
if blocks(bx,by)=10 then
 lives=lives+1
 blocks(bx,by)=0
fi
if dx<0 then
dx=int(ran(5))+bspeed
dx=-dx
fi
if dx>0 then
dx=-dx
dx=-int(ran(5))+bspeed
fi
dy=-dy
fi
label breakit
sqx=sqx+50
next bx
sqy=sqy+50
next by
return


label moveball
x=x+dx : y=y+dy
if y<=32 dy=-dy
if x<=32 then
dx=-dx
dx=int(ran(5))+bspeed
fi
if x>=490 then
dx=-int(ran(5))+bspeed
dx=-dx
fi
r=5:s=(200-r)/8
ang=0 
setrgb 1,255,255,255
setrgb 2,40,40,40
setrgb 3,40,40,40
repeat 
xo1=cosines(ang)*r:yo1=sines(ang)*r
xo2=cosines(ang+s)*r:yo2=sines(ang+s)*r
gtriangle x,y to x+xo1,y+yo1 to x+xo2,y+yo2 
gtriangle x,y to x-xo1,y+yo1 to x-xo2,y+yo2 
gtriangle x,y to x-xo1,y-yo1 to x-xo2,y-yo2 
gtriangle x,y to x+xo1,y-yo1 to x+xo2,y-yo2 
ang=ang+s
until (ang>90) 
return


label movebat
con=peek("port1")
if con=32 batx=batx+10
if con=128 batx=batx-10
if batx<=62 batx=62
if batx>=468 batx=468
setrgb 1,0,200,0
setrgb 2,0,100,0
setrgb 3,0,100,0
gtriangle batx,495 to batx+30,500 to batx+30,490
gtriangle batx,495 to batx+30,500 to batx-30,500
gtriangle batx,495 to batx-30,500 to batx-30,490
gtriangle batx,495 to batx-30,490 to batx+30,490
setrgb 1,150,255,150
line batx-30,490 to batx+30,490
line batx-30,490 to batx-30,500
return


label col
if x>=batx-30 and x<=batx+30 and y>=490 then 
dy=int(ran(3))+bspeed
dy=-dy
fi
if y>=510 then
lives=lives-1
y=100 : x=300
batx=320
fi
return


label death
repeat
con=peek("port1")
setdrawbuf dw
dw=1-dw
setdispbuf dw
setrgb 0,0,0,0
clear window
setrgb 1,255,255,255
text 220,200,"G A M E  O V E R"
text 200,300,"<press X to quit>"
until(and(con,16384)>0)
end


label win
repeat
con=peek("port1")
setdrawbuf dw
dw=1-dw
setdispbuf dw 
setrgb 0,0,0,0
clear window
setrgb 1,255,255,255
text 220,200,"L E V E L  C L E A R"
text 200,300,"<press X to continue>"
until(and(con,16384)>0)
level=level+1 
if level>maxlevel gosub winall
gosub progresslevel
goto setup


label winall
repeat
con=peek("port1")
setdrawbuf dw
dw=1-dw
setdispbuf dw
setrgb 0,0,0,0
clear window
setrgb 1,255,255,255
text 180,200,"ALL LEVELS CLEAR!! WELL DONE!!"
text 200,300,"<press X to quit>"
until(and(con,16384)>0)
end


label progresslevel
dim blocks(7,3)
for by=1 to 3
for bx=1 to 7
read blocks(bx,by)
next bx
next by
return


data 2,1,1,0,1,1,2
data 0,1,1,0,1,1,0
data 2,1,1,0,1,1,2

data 1,1,1,0,1,1,1
data 2,1,2,0,2,1,2
data 1,1,1,3,1,1,1

data 1,2,1,2,1,2,1
data 2,3,2,10,2,3,2
data 1,2,1,2,1,2,1

data 10,0,0,10,0,0,10
data 0,0,0,3,0,0,0
data 1,0,2,20,2,0,1

data 2,20,2,1,2,20,2
data 2,3,2,20,2,3,2
data 2,20,2,1,2,20,2

data 20,3,3,3,3,3,20
data 20,2,2,10,2,2,20
data 20,20,20,20,20,20,20

data 3,3,3,2,3,3,3
data 20,20,20,10,20,20,20
data 1,1,1,1,1,1,1

data 3,1,2,3,1,2,3
data 2,3,1,2,3,1,2
data 1,2,3,1,2,3,1



