rem "fight5" by Jo morrow.
rem I MADE THIS AGES AGO THUS, THE TERRIBLE LAYOUT, 
rem MILLIONS OF POINTLESS VARIABLES AND STUFF LIKE THAT. 
rem I JUST NEVER GOT ROUND TO CLEANING IT UP. -Jo

rem IN 'FIGHT5' THE AIM IS To KILL YOUR OPPONENT.
rem x=shoot    R1=invisile    L1=bomb 
rem (this has a 50% chance of killing you instead of 
rem your enemy so use it with care.



1 close window
open window 640,512
b1=500
b2=500
fx=0
fy=0
px=0
py=0

life1=310
life2=310
label loop
gosub setup
setdrawbuf dw
dw=1-dw
setdispbuf dw
clear window
shield=0
shield2=0
gosub checkeys
gosub man
gosub shots
gosub loop


label setup
a=50
b=430
c=40
d=470
e=60
f=445
g=495
h=440
i=78
j=59
k=41
l=95
m=83
n=32
o=472
p=452

q=50
r=230
s=40
t=270
u=60
v=245
w=295
x=240
y=78
z=59
A=41
B=95
C=83
D=32
E=272
F=252
G=20
H=40
I=0
J=10
K=15
L=65
return


label man
setrgb 1,150,150,150
text 10,500,"P1 Ammo: "+str$(b1)+" shots remaining"
text 330,500,"P2 Ammo: "+str$(b2)+" shots remaining"


setrgb 1,150,150,150
fill rectangle 10,5 to (life1),15
if shield=0 then
setrgb 1,150,150,150
endif
if shield=1 then
setrgb 1,0,0,0
endif

fill circle (fx+a),(fy+b),12
fill rectangle (fx+c),(fy+d) to (fx+e),(fy+f)
line (fx+c),(fy+f) to (fx+n),(fy+o)
line (fx+e),(fy+f) to (fx+i),(fy+f)
line (fx+j),(fy+d) to (fx+j),(fy+g)
line (fx+k),(fy+d) to (fx+k),(fy+g)
fill rectangle (fx+i),(fy+h) to (fx+l),(fy+f)
fill rectangle (fx+i),(fy+h) to (fx+m),(fy+p)
REM MAN2
setrgb 1,0,100,100

fill rectangle 640,5 to (640-life2),15
if shield2=0 then
setrgb 1,0,100,100
endif
if shield2=1 then
setrgb 1,0,0,0
endif

fill circle (px+q),(py+r),12
fill rectangle (px+s),(py+t) to (px+u),(py+v)
line (px+G),(py+v) to (px+H),(py+v)
line (px+z),(py+t) to (px+z),(py+w)
line (px+A),(py+t) to (px+A),(py+w)
line (px+u),(py+v) to (px+L),(py+E)
fill rectangle (px+G),(py+x) to (px+I),(py+v)
fill rectangle (px+G),(py+x) to (px+K),(py+F)
return

label checkeys
X=0
Z=0
c1=peek("port1")
c2=peek("port2")
if (and(c1,128)<>0) fx=fx-8
if fx<0 then
fx=549
endif
if (and(c1,32)<>0) fx=fx+8
if fx>549 then
fx=0
endif
if (and(c1,16)<>0) fy=fy-8
if fy>0 then
fy=-400
endif
if (and(c1,64)<>0) fy=fy+8
if fy<-400 then
fy=0
endif
if (and(c2,128)<>0) px=px-8
if px<0 then
px=549
endif
if (and(c2,32)<>0) px=px+8
if px>549 then
px=0
endif
if (and(c2,16)<>0) py=py-8
if py>200 then
py=-200
endif
if (and(c2,64)<>0) py=py+8
if py<-200 then
py=200
endif
if (and(c1,16384)<>0) X=1
if (and(c2,16384)<>0) Z=1
if (and(c1,2048)<>0) shield=1
if (and(c2,2048)<>0) shield2=1
if peek("port1")=1024 then
gosub bang
endif
if peek("port2")=1024 then
gosub bang
endif
return

label bang
X=ran(10)
if X<5 then
gosub kill1
endif
if X>5 then
gosub kill2
endif
return

label kill1
setrgb 1,255,0,0
close window
open window 640,512
fill rectangle 0,0 to 640,512
wait 1
gosub p1win

label kill2
setrgb 1,255,0,0
close window
open window 640,512
fill rectangle 0,0 to 640,512
wait 1
gosub p2win

label shots
if X=1 and b1>0 then
b1=b1-1
setrgb 1,225,0,0
line (fx+l),(fy+h+2) to 640,(fy+h+2)
if (fx+1)<(px+I) and (fy+h+2)<(py+v-2)+30 and (fy+h+2)>(py+v-2)-20 then
life2=life2-10
if life2<0 then
gosub p1win
endif
endif
endif
if Z=1 and b2>0 then
setrgb 1,255,0,0
b2=b2-1
line (px+I),(py+v-2) to 0,(py+v-2)
if (px+I)>(fx+1) and (py+v-2)<(fy+h+2)+30 and (py+v-2)>(fy+h+2)-20 then
life1=life1-10
if life1<0 then
gosub p2win
endif
endif
endif
return

label p1win
close window
open window 640,512
setrgb 1,200,200,200
text 240,256,"PLAYER1 WINs!"
20 if peek("port1")=64 then
goto 1
endif
goto 20


label p2win
close window
open window 640,512
setrgb 1,200,200,200
text 240,256,"PLAYER2 WINs!"
10 if peek("port2")=64 then
goto 1
endif
goto 10


