Added subs and collision detection.

This commit is contained in:
Rob Greene 2018-07-13 23:16:19 -05:00
parent a35ab37419
commit 87c5930b0c
1 changed files with 28 additions and 15 deletions

View File

@ -1,19 +1,22 @@
10 gosub 50000:goto 100
20 for i=1 to mm:if dx(i) then next i:return
30 dx(i)=x:dy(i)=15:ds(i)=dc:return
30 dx(i)=x:dy(i)=wc:ds(i)=dc:return
100 hgr:vtab 21
110 hcolor=6:hplot 0,13 to 279,13
110 wl=40:ws=wl-3:wc=wl+2
110 hcolor=6:hplot 0,wl to 279,wl
120 hcolor=3
130 x=140:sd=0:s=sh
140 di=1:mm=5: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
160 bs=0:bx=0:by=0:bd=0
200 xdraw s at x,10:ox=x:os=s
210 ox(di)=dx(di):oy(di)=dy(di):os(di)=ds(di)
220 if dx(di) then xdraw ds(di) at dx(di),dy(di)
200 xdraw s at x,ws:ox=x:os=s
210 if bx then xdraw bs at bx,by:cx=bx:cs=bs:cx=bx:cy=by
220 ox(di)=dx(di):oy(di)=dy(di):os(di)=ds(di)
230 if dx(di) then xdraw ds(di) at dx(di),dy(di)
300 ky=peek(-16384):if ky < 128 then 400
310 poke -16368,0
@ -23,18 +26,28 @@
350 if sd < -3 then sd=-3
360 if ky=160 then gosub 20
400 x=x+sd
410 if x < 10 then x=10
420 if x > 270 then x=270
400 if not bx then 450
410 bx=bx+bd
420 if bx < 10 or bx > 270 then bs=0:bx=0:by=0:bd=0
430 goto 500
450 rr=rnd(1):if rr < 0.10 then 480
460 if rr > 0.20 then 500
470 bx=10:by=wl+10+rnd(1)*80:bd=1:bs=sb+1:goto 500
480 bx=270:by=wl+10*rnd(1)*80:bd=-1:bs=sb
500 if not dx(di) then 590
510 ds(di)=ds(di)+1:if ds(di) > dc+3 then ds(di)=dc
520 dy(di)=dy(di)+3:if dy(di) > 160 then dx(di)=0:dy(di)=0:ds(di)=0
590 di=di+1:if di > mm then di = 1
500 x=x+sd
510 if x < 10 then x=10
520 if x > 270 then x=270
600 if ox(di) then xdraw os(di) at ox(di),oy(di)
610 xdraw os at ox,10
620 goto 200
600 if not dx(di) then 690
610 ds(di)=ds(di)+1:if ds(di) > dc+3 then ds(di)=dc
620 dy(di)=dy(di)+3:if dy(di) > 160 then dx(di)=0:dy(di)=0:ds(di)=0
690 di=di+1:if di > mm then di = 1
700 if ox(di) then xdraw os(di) at ox(di),oy(di)
710 if cx then xdraw cs at cx,cy:if peek(234) then print "BOOM!":bx=0:cx=0
720 xdraw os at ox,ws
730 goto 200
49999 end
50000 $shape src="ships.st", poke=yes, init=yes, assign=(sb="sub-left", sh="ship-left", dc="depthcharge-1")