Tanx


Tanx is a two player game in which two guns are placed on either side of a range of randomly generated hills. Each player takes turns in attempting to hit the gun on the other side by entering the angle and velocity of fire. The winner is the player with the highest score after a total of seven hits have been made. Your best chance of success is to use the smallest possible angle of elevation for a given velocity and, at higher speeds, it may be possible to fire through one of the hills.

    5 REM**TANX**BBC VERSION*
   10 MODE2
   20 GOSUB780
   30 sc1=0:sc2=0
   40 GOSUB1150
   50 MODE2
   60 GCOL3,7
   70 COLOUR128:CLS:c=0:GOSUB920
   80 GOTO100
   90 IFRND(1)>.5 c=c+1:GOSUB420
  100 GOSUB170
  110 c=c+1
  120 IFc=8 GOTO80
  130 GOSUB420
  140 c=c+1
  150 IFc=8 GOTO80
  160 GOTO100
  170 PRINTTAB(1,26)SPC(100);
  180 COLOUR11:PRINTTAB(1,26)"PLAYER 1":INPUT
TAB(1,27)"ENTER ELEVATION (0 TO 90)   "a
  190 IFa>90 ORa<0 GOTO170
  200 a=RAD(a)
  210 INPUTTAB(1,29)"ENTER VELOCITY (2 TO 10)
"v
  220 IFv<2 ORv>10 GOTO210
  230 s1=f1
  240 o1=f1
  250 e=v*8*SIN(a)
  260 D%=0:k=1280
  270 FORg=64 TO1280 STEPv*8*COS(a)
  280   IFD%>0 GOTO330
  290   IFs1>0 ANDs1<1024 ANDg>10 ANDPOINT(g,
s1)>0 k=g:SOUND1,-15,5,2:D%=POINT(g,s1)
  300   IFs1>0 ANDs1<1024 PLOT69,g,s1
  310   s1=s1+e
  320   e=e-1
  330 NEXTg
  340 e=v*SIN(a)*8:FORg=64 TOk STEPv*8*COS(a)
  350   IFo1>0 ANDo1<1024 PLOT69,g,o1
  360   o1=o1+e
  370   e=e-1
  380 NEXTg
  390 IFD%=2 GOSUB660:GOTO740
  400 RETURN
  410 IFc=9 CLS:GOTO30
  420 PRINTTAB(1,26)SPC(100);
  430 COLOUR14:PRINTTAB(1,26)"PLAYER 2":INPUT
TAB(1,27)"ENTER ELEVATION (0 TO 90)   "a
  440 IFa>90 ORa<0 GOTO420
  450 a=RAD(a)
  460 INPUTTAB(1,29)"ENTER VELOCITY (2 TO 10)
"v
  470 IFv<2 ORv>10 GOTO460
  480 s1=f2
  490 o1=f2
  500 e=v*8*SIN(a)
  510 D%=0:k=0
  520 FORg=1216 TO0 STEP-v*8*COS(a)
  530   IFD%>0 GOTO580
  540   IFs1>0 ANDs1<1024 ANDg<1152 ANDPOINT(
g,s1)>0 k=g:SOUND1,-15,5,2:D%=POINT(g,s1)
  550   IFs1>0 ANDs1<1024 PLOT69,g,s1
  560   s1=s1+e
  570   e=e-1
  580 NEXTg
  590 e=v*8*SIN(a):FORg=1216 TOk STEP-v*8*COS
(a)
  600   IFo1>0 ANDo1<1024 PLOT69,g,o1
  610   o1=o1+e
  620   e=e-1
  630 NEXTg
  640 IFD%=2 GOSUB700:GOTO740
  650 RETURN
  660 FORf=1 TO100:SOUND1,-15,RND(25),.1:NEXT
f
  670 PRINTTAB(19,q2)" "
  680 sc1=sc1+1
  690 RETURN
  700 FORf=1 TO100:SOUND1,-15,RND(25),.1:NEXT
f
  710 PRINTTAB(0,q1)" "
  720 sc2=sc2+1
  730 RETURN
  740 CLS:PRINTTAB(0,10)"PLAYER 1 HAS ";sc1" 
PTS"'''"PLAYER 2 HAS ";sc2" PTS"
  750 *FX15
  760 IFsc1+sc2=7 PRINTTAB(1,16)"GAME OVER:AN
Y KEY TO PLAY":X=GET:CLS:sc1=0:sc2=0
  770 FORX=0 TO3000:NEXT:GOTO70
  780 q1=0:q2=6:e=12:v=18:FORf=21 TO1 STEP-1
  790   COLOUR2:PRINTTAB(q1,f);"T":COLOUR6:PR
INTTAB(q2,f);"A":COLOUR3:PRINTTAB(e,f);"N":CO
LOUR7:PRINTTAB(v,f);"X"
  800   SOUND1,-15,f,1
  810   IFf>1 PRINTTAB(q1,f)" "TAB(q2,f)" "TA
B(e,f)" "TAB(v,f)" "
  820   IFf=14 ORf=7 q1=q1+2:e=e-2:v=v-4
  830 NEXT f
  840 PRINT"The 2 players take  it in turn to
 enter the angle and velocity  at which they 
 want to fire to try and hit their        opp
onent."
  850 PRINT"The shells must be  fired over th
e hillsbut if you are lucky your shell may be
  able to go through a hill (particularly at 
the higher speeds)"
  860 PRINT"The winner is the   player who ha
s hit  his opponent the    most after a total
  of 7 hits have been made."
  870 PRINT"To stand the best   chance of hit
ting   your opponent try to use the smallest 
  possible angle of   elevation."
  880 PRINT"PRESS ANY KEY":X=GET:CLS
  890 PRINT'''"The flashing caption at the bo
ttom of   the screen indicates whose go it is
."
  900 PRINT'''"ANY KEY TO START"
  910 X=GET:CLS:RETURN
  920 q=26-RND(13)
  930 FORf=2 TO17
  940   FORg=25 TOq STEP-1
  950     COLOUR5:COLOUR134:PRINTTAB(f,g)CHR$
226
  960     IFf=2 PRINTTAB(f-2,g)CHR$226;CHR$22
6
  970     IFf=17 PRINTTAB(f,g)CHR$226;CHR$226
;CHR$226
  980   NEXTg
  990   q=q+RND(8)-RND(8)
 1000   IFq<3 q=4+RND(2)
 1010   IFq>17 q=17
 1020 NEXTf
 1030 X%=0:Z%=0
 1040 FORf=1 TO30
 1050   IFX%=1 GOTO1080
 1060   Z%=FNATTR(0,f):IFZ%=5 ORZ%=6 COLOUR2:
COLOUR128:PRINTTAB(0,f-1)CHR$224:X%=1
 1070   IFX%=1 f1=(31-f)*32+64:q1=f-1
 1080 NEXTf
 1090 X%=0:Z%=0:FORf=1 TO30
 1100   IFX%=1 GOTO1130
 1110   Z%=FNATTR(19,f):IFZ%=5 ORZ%=6 COLOUR2
:COLOUR128:PRINTTAB(19,f-1)CHR$225:X%=1
 1120   IFX%=1 f2=(31-f)*32+64:q2=f-1
 1130 NEXTf
 1140 RETURN
 1150 VDU23,224,0,1,2,60,56,255,255,127
 1160 VDU23,225,0,128,64,60,28,255,255,127
 1170 VDU23,226,170,85,170,85,170,85,170,85
 1180 RETURN
 1190 DEFFNATTR(X%,Y%)
 1200 LOCALA%,B%,R%
 1210 C=0
 1220 A%=(X%+1)*64-32
 1230 B%=(Y%+1)*-32+1032
 1240 FORR%=A% TOA%+12
 1250   Z=POINT(R%,B%)
 1260   IFZ<>0 C=Z
 1270 NEXT
 1280 =C