1 ' THE PORTLAND IBM PERSONAL COMPUTER CLUB
2 ' ARTILL.BAS
3 ' Submitted by Joe Lipska,  July 1982
4 '
30 DEF SEG=0
40 IF (PEEK(&H410) AND &H30)<>&H30 THEN DEF SEG:GOTO 110
50 WIDTH 80:CLS:LOCATE 3,1
60 PRINT "HOLD IT!"
70 PRINT "YOU'RE NOT USING THE COLOR/GRAPHICS MONITOR ADAPTER!"
80 PRINT "THIS PROGRAM USES GRAPHICS AND REQUIRES THAT ADAPTER."
90 PRINT "SORRY,BUT THIS PROGRAM WILL NOT CONTINUE."
100 END
110 TIM$=RIGHT$(TIME$,2)
120 RIM=ASC(RIGHT$(TIM$,1))
130 RIM=RIM+ASC(LEFT$(TIM$,1))
140 RANDOMIZE(RIM)
150 DEF SEG=0:POKE &H417,96
160 DEG=.017745329#
170 KEY OFF:CLS:WIDTH 40
180 INPUT "A 0=MONOCROME  1=COLOR";A
190 CLS
200 PRINT  "              ARTILLARY"
210 PRINT " To shoot shells input ANGLE,VELOCITY "
220 PRINT " an example is  70,100"
230 PRINT
240 PRINT " Wind can vary both in direction and in"
250 PRINT " strength if you choose this option"
260 PRINT
270 PRINT " Each gun company starts with 100 men."
280 PRINT " After each shot there is a deserter"
290 PRINT " on each side.  Near misses can cause"
300 PRINT " casualties, dependent on distance and"
310 PRINT " # of men remaining. A near miss which"
320 PRINT " would bring a gun company to less than"
330 PRINT " 10 men is treated as a direct hit. A"
340 PRINT " running total of base strength is"
350 PRINT " maintained between battles for each "
360 PRINT " side. Misses leaves craters; therefore"
370 PRINT " shots can be used to lower a large"
380 PRINT " mountain!"
390 PRINT " If desertion brings your gun company"
400 PRINT " to less than 5 men, your gun misfires"
410 INPUT " (PRESS RETURN TO CONTINUE)";ZZZ$: CLS
420 PRINT
430 INPUT "TYPE Y IF YOU WANT VARYING WIND";Q$:Q$=LEFT$(Q$,1)
440  Q1=0
450 SCREEN 1:COLOR A,1
460  IF Q$<>"Y" THEN 500
470 Q1=1
480 PRINT "LEVEL OF DIFFICULTY":INPUT"     1=EASY,20=DIFFICULT";LEVEL
490 IF LEVEL <1 OR LEVEL>20 THEN 480
500 DIM H(320),A1(2),A2(2), B1(4),B2(4),L(2),T1(2),M1(2)
510 DIM E1(2),V1(2),WINDOW(18)
520 N=1.5+-1^ INT(100*RND(1))*.5
530 CLS
540 LINE (0,0)-(14,14),3,B
550 PAINT (1,1),3,3
560 GET (1,1)-(13,13),WINDOW
570 PLAY "MBO2T230L3CL5MSFP8FL4ACL2FL4CL5MSFAL4O3CO2AP14FP14L1C"
580 CLS
590 PLAY "MBP6L3CL4MSFFFFP4L3CL4MSFFFF"
600 PLAY "MBT230P3O3L3CO2L2AL4FL3CCL1F"
610 RESTORE
620 DATA -1,1,1,-1,-1,-1,1,1
630 T1(1)=0
640 T1(2)=0
650 M1(1)=101
660 M1(2)=101
670 A1(1)=2
680 A1(2)=2
690 A2(1)=4
700 A2(2)=27
710 FOR L=1 TO 4
720 READ B1(L)
730 NEXT L
740 FOR L=1 TO 4
750 READ B2(L)
760 NEXT L
770 E1(1)=0
780 E1(2)=0
790 V1(1)=0
800 V1(2)=0
810 N2=0
820 E3=0
830 V3=0
840 REM ESTABLISH BASE LOCATIONS
850 X1=INT(53+RND(1)*60)
860 X2=INT(198+RND(1)*60)
870 L(1)=INT(20+(X1-20)*RND(1))
880 L(2)=INT(X2+(300-X2)*RND(1))
890 REM ESTABLISH LEFT & RIGHT ELEVATIONS
900 HGT1=RND(1)*98+2
910 HGT2=RND(1)*98+2
920 IF HGT1<>HGT2 THEN 960
930 HGT1=15
940 HGT2=15
950 GOTO 1020
960 IF HGT1>HGT2 THEN 1000
970 HGT2=15+(HGT2-HGT1)
980 HGT1=15
990 GOTO 1020
1000 HGT1=15+(HGT1-HGT2)
1010 HGT2=15
1020 FOR I=1 TO X1
1030 H(I)=HGT1
1040 NEXT I
1050 H9=RND(1)*98+2
1060 FOR I=X2 TO 320
1070 H(I)=HGT2
1080 NEXT I
1090 REM PEAK ELEVATION
1100 X3=X1+INT(RND(1)*(X2-X1-20))+10
1110 H(X3)=RND(1)*90+50
1120 TOP=X3
1130 REM SLOPE OF FLAT LAND TO PEAK
1140 D1=(H(X3)-H(1))/2
1150 D2=(H(X3)-H(320))/2
1160 IF D1*D2<0 THEN 1360
1170 REM DRAW CURVE TO PEAK
1180 J=-180
1190 K=180/(X3-X1+1)
1200 H9=H(1)+D1
1210 FOR I=X1+1 TO X3-1
1220 J=J+K
1230 H(I)=H9+COS(J*DEG)*D1
1240 NEXT I
1250 J=0
1260 K=180/(X2-X3+1)
1270 H9=H(320)+D2
1280 REM DRAW CURVE FROM PEAK
1290 FOR I=X3+1 TO X2-1
1300 J=J+K
1310 IF I=321 THEN 1340
1320 H(I)=H9+COS(J*DEG)*D2
1330 NEXT I
1340 GOTO 1440
1350 REM DRAW CURVE FROM LEFT TO RIGHT
1360 D=(H(1)-H(320))/2
1370 J=0
1380 K=180/(X2-X1+1)
1390 H9=H(320)+D
1400 FOR I=X1+1 TO X2-1
1410 J=J+K
1420 H(I)=H9+COS(J*DEG)*D
1430 NEXT I
1440 REM DRAW TERAIN
1450 CLS
1460 LINE (X2,(200-H(X2)))-(319,(200-H(X2))),1
1470 LINE (0,(200-H(1)))-(X1,(200-H(X1))),1
1480 FOR I=X1 TO X2
1490 LINE -(I,(200-H(I))),1
1500 NEXT I
1510 PAINT (100,199),1
1520 REM DETERMINE WIND
1530 WIND=100*RND(1)-50
1540 W=((LEVEL*2)*RND(1))-LEVEL+WIND
1550 W=INT(W)
1560 IF W<1 THEN ARROW=27 ELSE ARROW=26
1570 IF W=0 THEN 1540
1580 N=3-N
1590 M1(N)=M1(N)-1
1600 M1(3-N)=M1(3-N)-1
1610 REM DRAW BASES
1620 XX=L(1)
1630 YY=200-H(L(1))
1640 LINE (XX-2,YY-2)-(XX+2,YY+2),,BF
1650 XX=L(2)
1660 YY=200-H(L(2))
1670 LINE (XX-2,YY-2)-(XX+2,YY+2),,BF
1680 REM PRINT TITLES
1690 LOCATE 1,2
1700 PRINT "ANGLE,SPEED MEN"
1710 LOCATE 1,25
1720 PRINT "ANGLE,SPEED MEN"
1730 LOCATE 2,14:PRINT USING "###";M1(1)
1740 LOCATE 2,37:PRINT USING "###";M1(2)
1750 LOCATE 1,19
1760 PRINT "Wind"
1770 LOCATE 2,18
1780 PRINT USING "##";ABS(W):LOCATE 2,21:PRINT "mph";
1790 LOCATE 3,12
1800 PRINT "              "
1810 LOCATE 3,20
1820 PRINT CHR$(ARROW)
1830 LOCATE A1(N),A2(N)
1840 PRINT USING "###";E1(N);
1850 PRINT ",";:PRINT USING "###";V1(N)
1860 LOCATE A1(N)+1,A2(N)-1
1870 PRINT "           "
1880 LOCATE A1(N)+1,A2(N)-1
1890 INPUT E$,V$
1900 E=VAL(E$):V=VAL(V$)
1910 IF E=0 OR V=0 THEN 1860
1920 E1(N)=E:V1(N)=V
1930 V=V/10
1940 IF M1(N)>5 THEN 1980
1950 E=90
1960 V=0
1970 W=1
1980 REM
1990 E=90-E
2000 C=1
2010 IF N=1 THEN 2040
2020 E=-E
2030 E3=-E3
2040 X1=L(N)
2050 Y1=H(L(N))
2060 T=0
2070 V1=SIN(E*DEG)*V
2080 V2=COS(E*DEG)*V
2090 T=T+.3
2100 IF T=.3 THEN 2120
2110 PRESET (X,200-Y)
2120 V1=V1+(V1+W)/1500
2130 X=X1+(V1+W/50)*T
2140 IF X<1 OR X>320 THEN 2670
2150 REM account for gravity and accelerarion
2160 Y=Y1+(V2-T/2.5)*T
2170 PSET (X,200-Y)
2180 IF Y-H(X)=>1 THEN 2090
2190 PRESET (X,200-Y)
2200 IF ABS(X-L(N))<1 AND T>.5 THEN 2710
2210 IF ABS (X-L(3-N))<1 THEN 2690
2220 IF T<.5 THEN 2090
2230 REM miss
2240 IF X<6 THEN 2570
2250 IF X>314 THEN 2570
2260 SOUND 179,3
2270 LINE (X-3,(200-H(X-3)))-(X-2,(200-H(X-2))),0
2280 FOR L=X-2 TO X+3
2290 LINE -(L,(200-H(L))),0
2300 NEXT L
2310 TMY=195-Y
2320 IF TMY>186 THEN 2570
2330 REM CHANGE LANDSCAPE
2340 PUT (X-6,TMY),WINDOW,PRESET
2350 TMPX=X-6:TMPY=205-Y
2360 H(X-3)=H(X-3)-1
2370 H(X-2)=H(X-2)-2
2380 H(X-1)=H(X-1)-3.5
2390 H(X)=H(X)-4
2400 H(X+1)=H(X+1)-3.5
2410 H(X+2)=H(X+2)-2
2420 H(X+3)=H(X+3)-1
2430 MIN=X-12
2440 MAX=X+12
2450 IF MIN<1 THEN MIN=1
2460 IF MAX>320 THEN MAX=320
2470 LINE (MIN,(200-H(MIN)))-(MIN+1,(200-H(MIN+1))),1
2480 FOR L=MIN+1 TO MAX
2490 LINE -(L,(200-H(L))),1
2500 NEXT L
2510 FOR PNTX=X-2 TO X+2
2520 PNTY=205-H(PNTX)
2530 IF PNTY>199 THEN PNTY=199
2540 PAINT (PNTX,PNTY),1,1
2550 PAINT (PNTX,201-H(PNTX)),1,1
2560 NEXT PNTX
2570 IF ABS(X-L(3-N))>8 THEN 2670
2580 REM near miss
2590 D9=2*ABS(X-L(3-N))
2600 D9=INT(M1(3-N)/D9)
2610 M1(3-N)=M1(3-N)-D9
2620 T1(3-N)=T1(3-N)+D9
2630 N2=1
2640 IF M1(3-N)<10 THEN 2690
2650 N2=0
2660 SOUND 179,5
2670 IF Q1=1 THEN 1540 ELSE 1580
2680 REM hit and explotion
2690 N=3-N
2700 PLAY "MBO1L16FP16FP16F"
2710 PSET (X,200-Y),2
2720 DRAW "H15E2F2E2F2E2F2E2F2E2F2E2F2E2F2E2F2G16C2"
2730 PAINT (X,199-Y),2,2
2740 LOCATE 1,1
2750 PRINT "                                       "
2760 PRINT "                                       "
2770 PRINT "                                      "
2780 LOCATE 1,1
2790 T1(N)=T1(N)+M1(N)
2800 PRINT  " CASUALTIES   left=" ;T1(1);" right=";T1(2)
2810 IF N2=1 THEN 2830
2820 N=3-N
2830 LOCATE 2,1
2840 PRINT " AGAIN?";
2850 INPUT A$:A$=LEFT$(A$,1)
2860 IF A$="N" THEN 2880
2870 PRINT "PLEASE WAIT 5 SECONDS":GOTO 610
2880 END
INT " AGAIN?";
2850 INPUT A$:A$=LEFT$(A$,1)
2860 IF A$="N" THEN 2880
2870 PRINT "PLEASE WAIT 5 SECONDS":GOTO 610
2880