100 init 110 randomize 120 score=0 130 radx=500 140 rady=160 150 radsx=10 160 radsy=5 170 rem ####################### title 180 mode=1 190 label title 200 locate 0,0 210 print "push select and start" 220 if mode=1 then print"1 player " else print"2 players" 230 if pad(1,19)=1 then 240 do 250 loop while pad(1,19)=1 260 if mode=1 then mode=2 else mode=1 270 end if 280 if pad(1,20)=1 then goto *init 290 fsync 1 300 goto *title 310 label init 320 do 330 loop while pad(1,20)=1 340 clear 350 rem #################### map init 360 dim cx(2),cz(2) 370 k=0 380 l=100 390 dim pat(11,11) 400 xs=100 410 zs=100 420 campos 1,-100,-120,-100 430 camrot 1,pi/12,-pi/4,0 440 if mode=2 then 450 campos 2,100,-120,100 460 camrot 2,pi/12,-pi/4,0 470 screen vertical 480 else 490 screen single 500 end if 510 ambcol 150,150,150 520 for i=1 to 11 530 for j=1 to 11 540 read pat(j,i) 550 if pat(j,i)=1 then 560 k=k+1 570 modset k+20,3,5 580 modpos k+20,i*xs,-30,j*zs 590 modopt k+20,2.5,1,0,1 600 moddisp k+20 610 else 620 l=l+1 630 modset l,3,3 640 modpos l,i*xs,70,j*zs 650 modopt l,2.5,1,0,1 660 moddisp l 670 end if 680 next j 690 next i 700 if mode=1 then 710 tilepos 100,radx+10,rady+5,620,220,1677500 720 tilecol 100,100,100,100,100 730 tiledisp 100 740 end if 750 rem #################### en init 760 if mode=2 then goto *tankinit 770 enum=4 780 dim ex(enum),ez(enum),ed(enum),em(enum),ec(enum) 790 n=200 800 for i=1 to enum 810 em(i)=1 820 ec(i)=0 830 n=n+1 840 do 850 x=int(rnd*6)+5 860 z=int(rnd*6)+5 870 ex(i)=x*xs 880 ez(i)=z*zs 890 mm=pat(x,z) 900 for j=1 to i-1 910 if ex(i)=ex(j) and ez(i)=ez(j) then mm=1 920 next j 930 loop while mm=1 940 modset n,7,2 950 modpos n,ex(i),0,ez(i) 960 ed(i)=rnd*pi*2 970 modrot n,0,ed(i),0 980 moddisp n 990 modset n+enum,5,9 1000 tilecol n,0,0,200,128 1010 call setradar(n,ez(i),ex(i)) 1020 tiledisp n 1030 next i 1040 rem ################## tank init 1050 label tankinit 1060 dim tx(2),tz(2),td(2),sx(2),sz(2),sd(2),sh(2),tb(2) 1070 tx(1)=200 1080 tz(1)=200 1090 sx(1)=-100 1100 sz(1)=-100 1110 sd(1)=0 1120 sh(1)=100 1130 td(1)=pi 1140 tb(1)=0 1150 tx(2)=1000 1160 tz(2)=1000 1170 sx(2)=-100 1180 sz(2)=-100 1190 sd(2)=0 1200 sh(2)=100 1210 td(2)=0 1220 tb(2)=0 1230 tcd=40 1240 modrot 1,0,td(1),0 1250 modset 1,7,1 1260 modpos 1,tx(1),0,tz(1) 1270 moddisp 1 1280 if mode=2 then 1290 modrot 2,0,td(2),0 1300 modset 2,7,1 1310 modpos 2,tx(2),0,tz(2) 1320 moddisp 2 1330 modset 5,5,1 1340 else 1350 tilecol 1,200,0,0,128 1360 tiledisp 1 1370 end if 1380 modset 4,5,9 1390 modset 6,5,9 1400 modset 7,4,10 1410 modpos 7,5*xs,0,5*zs 1420 modopt 7,3,1,0,1 1430 moddisp 7 1440 modset 3,5,1 1450 call setradar(1,tz(1),tx(1)) 1460 rem ##################### main? 1470 label main 1480 call tankmove(1) 1490 if pad(1,20)=1 then end 1500 if mode=1 then 1510 call enmove 1520 else 1530 call tankmove(2) 1540 end if 1550 locate 0,0 1560 if mode=1 then 1570 print"SCORE:";score 1580 else 1590 print"SHIELD:";sh(1) 1600 locate 0,13 1610 print"SHIELD:";sh(2) 1620 end if 1630 if mode=1 then 1640 n=1 1650 if collision(1,201,200+enum)>0 then goto *crash 1660 else 1670 n=0 1680 if sh(1)=0 and sh(2)=0 then 1690 n=3 1700 goto *crash 1710 elseif sh(1)=0 then 1720 n=1 1730 goto *crash 1740 elseif sh(2)=0 then 1750 n=2 1760 goto *crash 1770 end if 1780 end if 1790 fsync 1 1800 goto *main 1810 rem ##################### crash! 1820 label crash 1830 seplay 23,100,100 1840 for i=3 to 6 1850 modoff i 1860 next i 1870 if n=3 then 1880 vibrate 1,0,1,0.3 1890 vibrate 2,0,1,0.3 1900 modpos 4,tx(1),0,tz(1) 1910 modopt 4,0.5,1,0,1 1920 moddisp 4 1930 modpos 6,tx(2),0,tz(2) 1940 modopt 6,0.5,1,0,1 1950 moddisp 6 1960 else 1970 vibrate n,0,1,0.3 1980 modpos 4,tx(n),0,tz(n) 1990 modopt 4,0.5,1,0,1 2000 moddisp 4 2010 end if 2020 for i=0.5 to 2 step 0.05 2030 modopt 4,i,1,0,1 2040 if n=3 then modopt 6,i,1,0,1 2050 fsync 1 2060 next i 2070 if n=3 then 2080 modoff 4 2090 modoff 2 2100 modoff 6 2110 modoff 1 2120 else 2130 modoff n 2140 modoff 4 2150 end if 2160 end 2170 rem #################### en move 2180 sub enmove 2190 for i=1 to enum 2200 if ec(i)>0 then 2210 ehh=200+i+enum 2220 ec(i)=ec(i)+0.1 2230 modopt ehh,ec(i),1,0,1 2240 if ec(i)>3 then 2250 ec(i)=0 2260 modoff ehh 2270 end if 2280 else 2290 if em(i)=1 then ve=-5 else ve=3 2300 x=ve*sin(ed(i)) 2310 z=ve*cos(ed(i)) 2320 modpos 200+i,ex(i)+x,0,ez(i)+z 2330 if collision(200+i,21,21+k)>0 then 2340 modpos 200+i,ex(i),0,ez(i) 2350 em(i)=-em(i) 2360 else 2370 ex(i)=ex(i)+x 2380 ez(i)=ez(i)+z 2390 end if 2400 if em(i)=1 and rnd<0.4 then 2410 pd=pi/40 2420 if rnd<0.5 then ed(i)=ed(i)+pd else ed(i)=ed(i)-pd 2430 if ed(i)<0 then ed(i)=ed(i)+pi*2 2440 if ed(i)>pi*2 then ed(i)=ed(i)-pi*2 2450 modrot 200+i,0,ed(i),0 2460 end if 2470 call setradar(i+200,ez(i),ex(i)) 2480 end if 2490 next i 2500 end sub 2510 rem ###################### radar 2520 sub setradar(n,x,y) 2530 x1=radx+x/10 2540 y1=rady+y/20 2550 x2=x1+radsx 2560 y2=y1+radsy 2570 tilepos n,x1,y1,x2,y2,16777200-n 2580 end sub 2590 rem ################## tank move 2600 sub tankmove(n) 2610 cx(n)=-tcd*sin(td(n)) 2620 cz(n)=-tcd*cos(td(n)) 2630 campos n,tx(n)-cx(n),-20,tz(n)-cz(n) 2640 camvec n,cx(n),0,cz(n) 2650 px=pad(n,14)-127 2660 py=pad(n,13)-127 2670 if tb(n)>0 then 2680 tb(n)=tb(n)+0.05 2690 if tb(n)>1.5 then 2700 tb(n)=0 2710 modoff 2+2*n 2720 else 2730 modopt 2+2*n,tb(n),1,0,1 2740 end if 2750 end if 2760 if abs(px)>30 then 2770 ppx=px/5000 2780 td(n)=td(n)+ppx 2790 if td(n)<0 then td(n)=td(n)+pi*2 2800 if td(n)>pi*2 then td(n)=td(n)-pi*2 2810 modrot n,0,td(n),0 2820 end if 2830 if abs(py)>30 then 2840 tkv=py/40 2850 xx=tkv*sin(td(n)) 2860 zz=tkv*cos(td(n)) 2870 modpos n,tx(n)+xx,0,tz(n)+zz 2880 if collision(n,21,21+k)=0 then 2890 tx(n)=tx(n)+xx 2900 tz(n)=tz(n)+zz 2910 else 2920 ! seplay 26,100,100 2930 ! vibrate 1,0,1,0.1 2940 modpos n,tx(n),0,tz(n) 2950 end if 2960 if mode=1 then call setradar(1,tz(n),tx(n)) 2970 if tb(n)>0 then modpos 2+2*n,tx(n),0,tz(n) 2980 end if 2990 nl=1+2*n 3000 if pad(n,6)>30 and sx(n)<0 then 3010 seplay 9,100,100 3020 sx(n)=tx(n) 3030 sz(n)=tz(n) 3040 sd(n)=td(n) 3050 modpos nl,sx(n),0,sz(n) 3060 modrot nl,0,sd(n),0 3070 moddisp nl 3080 elseif sx(n)>0 then 3090 sx(n)=sx(n)-15*sin(sd(n)) 3100 sz(n)=sz(n)-15*cos(sd(n)) 3110 modpos nl,sx(n),0,sz(n) 3120 if collision(nl,21,21+k)>0 then 3130 modoff nl 3140 sx(n)=-100 3150 else 3160 if mode=2 then 3170 if collision(nl,3-n,3-n)>0 and tb(3-n)=0 then 3180 sh(3-n)=sh(3-n)-10 3190 if sh(3-n)>0 then 3200 vibrate 3-n,0,1,0.1 3210 seplay 18,100,100 3220 end if 3230 modoff nl 3240 sx(n)=-100 3250 nrb=2+2*(3-n) 3260 tb(3-n)=0.5 3270 modpos nrb,tx(3-n),0,tz(3-n) 3280 modopt nrb,tb(3-n),1,0,1 3290 moddisp nrb 3300 end if 3310 else 3320 eh=collision(3,201,200+enum) 3330 if eh>0 and ec(eh-200)=0 then 3340 seplay 23,100,100 3350 score=score+10 3360 modoff 3 3370 sx(n)=-100 3380 ehh=eh-200 3390 ec(ehh)=0.5 3400 modpos eh+enum,ex(ehh),0,ez(ehh) 3410 modopt eh+enum,ec(ehh),1,0,1 3420 moddisp eh+enum 3430 end if 3440 end if 3450 end if 3460 end if 3470 end sub 10000 rem ######################## 10010 data 1,1,1,1,1,1,1,1,1,1,1 10020 data 1,0,0,0,0,0,0,0,0,0,1 10030 data 1,0,0,0,0,0,0,0,0,0,1 10040 data 1,0,0,1,0,0,0,1,0,0,1 10050 data 1,0,0,0,0,0,0,0,0,0,1 10060 data 1,0,0,0,0,0,0,0,0,0,1 10070 data 1,0,0,0,0,0,0,0,0,0,1 10080 data 1,0,0,1,0,0,0,1,0,0,1 10090 data 1,0,0,0,0,0,0,0,0,0,1 10100 data 1,0,0,0,0,0,0,0,0,0,1 10110 data 1,1,1,1,1,1,1,1,1,1,1