100 init 110 randomize 120 score=0 130 radx=500 140 rady=160 150 radsx=10 160 radsy=5 170 rem ################### map init 180 k=0 190 l=100 200 dim pat(11,11) 210 xs=100 220 zs=100 230 campos 1,-100,-120,-100 240 camrot 1,pi/12,-pi/4,0 250 ambcol 150,150,150 260 for i=1 to 11 270 for j=1 to 11 280 read pat(j,i) 290 if pat(j,i)=1 then 300 k=k+1 310 modset k+20,3,5 320 modpos k+20,i*xs,-30,j*zs 330 modopt k+20,2.5,1,0,1 340 moddisp k+20 350 else 360 l=l+1 370 modset l,3,3 380 modpos l,i*xs,70,j*zs 390 modopt l,2.5,1,0,1 400 moddisp l 410 end if 420 next j 430 next i 440 tilepos 100,radx+10,rady+5,620,220,1677500 450 tilecol 100,100,100,100,100 460 tiledisp 100 470 rem #################### en init 480 enum=4 490 dim ex(enum),ez(enum),ed(enum),em(enum),ec(enum) 500 n=200 510 for i=1 to enum 520 em(i)=1 530 ec(i)=0 540 n=n+1 550 do 560 x=int(rnd*6)+5 570 z=int(rnd*6)+5 580 ex(i)=x*xs 590 ez(i)=z*zs 600 mm=pat(x,z) 610 for j=1 to i-1 620 if ex(i)=ex(j) and ez(i)=ez(j) then mm=1 630 next j 640 loop while mm=1 650 modset n,7,2 660 modpos n,ex(i),0,ez(i) 670 ed(i)=rnd*pi*2 680 modrot n,0,ed(i),0 690 moddisp n 700 modset n+enum,5,9 710 tilecol n,0,0,200,128 720 call setradar(n,ez(i),ex(i)) 730 tiledisp n 740 next i 750 rem ################## tank init 760 tx=200 770 tz=200 780 sx=-100 790 sz=-100 800 sd=0 810 td=pi 820 tcd=40 830 modrot 1,0,td,0 840 modset 1,7,1 850 modpos 1,tx,0,tz 860 moddisp 1 870 modset 2,4,10 880 modpos 2,5*xs,0,5*zs 890 modopt 2,3,1,0,1 900 moddisp 2 910 modset 3,5,1 920 call setradar(1,tz,tx) 930 tilecol 1,200,0,0,128 940 tiledisp 1 950 rem ##################### main 960 label main 970 cx=-tcd*sin(td) 980 cz=-tcd*cos(td) 990 campos 1,tx-cx,-20,tz-cz 1000 camvec 1,cx,0,cz 1010 px=pad(1,14)-127 1020 py=pad(1,13)-127 1030 if abs(px)>30 then 1040 ppx=px/5000 1050 td=td+ppx 1060 if td<0 then td=td+pi*2 1070 if td>pi*2 then td=td-pi*2 1080 modrot 1,0,td,0 1090 end if 1100 if abs(py)>30 then 1110 tkv=py/40 1120 xx=tkv*sin(td) 1130 zz=tkv*cos(td) 1140 modpos 1,tx+xx,0,tz+zz 1150 if collision(1,21,21+k)=0 then 1160 tx=tx+xx 1170 tz=tz+zz 1180 else 1190 tx=tx-xx 1200 tz=tz-zz 1210 modpos 1,tx,0,tz 1220 end if 1230 call setradar(1,tz,tx) 1240 end if 1250 if pad(1,6)>30 and sx<0 then 1260 sx=tx 1270 sz=tz 1280 sd=td 1290 modpos 3,sx,0,sz 1300 modrot 3,0,sd,0 1310 moddisp 3 1320 elseif sx>0 then 1330 sx=sx-15*sin(sd) 1340 sz=sz-15*cos(sd) 1350 modpos 3,sx,0,sz 1360 if collision(3,21,21+k)>0 then 1370 modoff 3 1380 sx=-100 1390 else 1400 eh=collision(3,201,200+enum) 1410 if eh>0 and ec(eh-200)=0 then 1420 score=score+10 1430 modoff 3 1440 sx=-100 1450 ehh=eh-200 1460 ec(ehh)=0.5 1470 modpos eh+enum,ex(ehh),0,ez(ehh) 1480 modopt eh+enum,ec(ehh),1,0,1 1490 moddisp eh+enum 1500 end if 1510 end if 1520 end if 1530 if pad(1,20)=1 then end 1540 call enmove 1550 if collision(1,201,200+enum)>0 then goto *crash 1560 locate 0,0 1570 print"SCORE:";score 1580 fsync 1 1590 goto *main 1600 rem ##################### crash! 1610 label crash 1620 modoff 3 1630 modset 4,5,9 1640 modpos 4,tx,0,tz 1650 modopt 4,0.5,1,0,1 1660 moddisp 4 1670 for i=0.5 to 2 step 0.05 1680 modopt 4,i,1,0,1 1690 fsync 1 1700 next i 1710 modoff 1 1720 modoff 4 1730 end 1740 rem #################### en move 1750 sub enmove 1760 for i=1 to enum 1770 if ec(i)>0 then 1780 ehh=200+i+enum 1790 ec(i)=ec(i)+0.1 1800 modopt ehh,ec(i),1,0,1 1810 if ec(i)>3 then 1820 ec(i)=0 1830 modoff ehh 1840 end if 1850 else 1860 if em(i)=1 then ve=-5 else ve=3 1870 x=ve*sin(ed(i)) 1880 z=ve*cos(ed(i)) 1890 modpos 200+i,ex(i)+x,0,ez(i)+z 1900 if collision(200+i,21,21+k)>0 then 1910 modpos 200+i,ex(i),0,ez(i) 1920 em(i)=-em(i) 1930 else 1940 ex(i)=ex(i)+x 1950 ez(i)=ez(i)+z 1960 end if 1970 if em(i)=1 and rnd<0.4 then 1980 pd=pi/40 1990 if rnd<0.5 then ed(i)=ed(i)+pd else ed(i)=ed(i)-pd 2000 if ed(i)<0 then ed(i)=ed(i)+pi*2 2010 if ed(i)>pi*2 then ed(i)=ed(i)-pi*2 2020 modrot 200+i,0,ed(i),0 2030 end if 2040 call setradar(i+200,ez(i),ex(i)) 2050 end if 2060 next i 2070 end sub 2080 rem ###################### radar 2090 sub setradar(n,x,y) 2100 x1=radx+x/10 2110 y1=rady+y/20 2120 x2=x1+radsx 2130 y2=y1+radsy 2140 tilepos n,x1,y1,x2,y2,16777200-n 2150 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 ÿ