From ba55fc2aafba41a8a2c64e24e8e86ab2f6416f52 Mon Sep 17 00:00:00 2001 From: Rob Greene Date: Fri, 13 Jul 2018 21:22:22 -0500 Subject: [PATCH] Multiple depth charges. --- samples/ships.bas | 62 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/samples/ships.bas b/samples/ships.bas index 4741790..381c68b 100644 --- a/samples/ships.bas +++ b/samples/ships.bas @@ -1,36 +1,44 @@ -10 gosub 50000 +10 gosub 50000:goto 100 -20 hgr -30 hcolor=6:hplot 0,13 to 279,13 +20 for i=1 to mm:if dx(i) then next i:return +30 dx(i)=x:dy(i)=15:ds(i)=dc:return -100 hcolor=3:x=140:sd=0:s=sh -110 dx=0:dy=0 +100 hgr:vtab 21 +110 hcolor=6:hplot 0,13 to 279,13 + +120 hcolor=3 +130 x=140:sd=0:s=sh +140 di=0:mm=3:dim dx(mm),dy(mm),ds(mm),ox(mm),oy(mm),os(mm) +150 for i=1 to mm:dx(i)=0:dy(i)=0:ds(i)=0:next i 200 xdraw s at x,10:ox=x:os=s -210 ky=peek(-16384):if ky > 127 then 300 -220 x=x+sd -225 gosub 400 -230 if x < 10 then x=10 -240 if x > 270 then x=270 -250 xdraw os at ox,10 -260 goto 200 +210 for i=1 to mm +220 ox(i)=dx(i):oy(i)=dy(i):os(i)=ds(i) +230 if dx(i) then xdraw ds(i) at dx(i),dy(i) +240 next i -300 poke -16368,0 -310 if ky=136 then s=sh:sd=sd-1:goto 399 -320 if ky=149 then s=sh+1:sd=sd+1:goto 390 -330 if ky=160 and not dx and not dy then dx=x:dy=15:ds=dc:xdraw ds at dx,dy:goto 390 -390 if abs(sd) > 3 then sd = sgn(sd)*3 -399 xdraw os at ox,10:goto 200 +300 ky=peek(-16384):if ky < 128 then 400 +310 poke -16368,0 +320 if ky=136 then s=sh:sd=sd-1 +330 if ky=149 then s=sh+1:sd=sd+1 +340 if sd > 3 then sd=3 +350 if sd < -3 then sd=-3 +360 if ky=160 then gosub 20 -400 if not dx and not dy then return -410 ax=dx:ay=dy:as=ds -420 dy=dy+2:if dy > 160 then dx=0:dy=0 -430 ds=ds+1:if ds > dc+3 then ds=dc -430 xdraw as at ax,ay -440 if not dx and not dy then return -450 xdraw ds at dx,dy -460 return +400 x=x+sd +410 if x < 10 then x=10 +420 if x > 270 then x=270 + +500 di=di+1:if di > mm then di = 1 +510 if not dx(di) then 600 +520 ds(di)=ds(di)+1:if ds(di) > dc+3 then ds(di)=dc +530 dy(di)=dy(di)+2:if dy(di) > 160 then dx(di)=0:dy(di)=0:ds(di)=0 + +600 xdraw os at ox,10 +610 for i=1 to mm +620 if ox(i) then xdraw os(i) at ox(i),oy(i) +630 next i +640 goto 200 49999 end 50000 $shape src="ships.st", poke=yes, init=yes, assign=(sb="sub-left", sh="ship-left", dc="depthcharge-1") - \ No newline at end of file