mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2024-12-22 07:30:19 +00:00
180 lines
4.7 KiB
Plaintext
180 lines
4.7 KiB
Plaintext
5 REM ARTILLERY #01
|
|
10 TEXT : HOME : SPEED= 255: NORMAL
|
|
15 HOME : VTAB (10): INPUT "INSTRUCTIONS?";A9$
|
|
16 IF LEFT$ (A9$,1) = "N" THEN 19
|
|
17 HOME : GOTO 20
|
|
19 HOME : TEXT : GOTO 150
|
|
20 PRINT TAB( 15): PRINT : PRINT : PRINT "ARTILLERY": PRINT : PRINT : PRINT : PRINT
|
|
21 PRINT " ARTILLERY IS A SIMULATION OF AN"
|
|
30 PRINT "ARTILLERY DUEL BETWEEN TWO SETS OF GUNS"
|
|
40 PRINT "ON EITHER SIDE OF A MOUNTAIN. BY USING"
|
|
50 PRINT "THE ANGLE OF THE GUN AND THE MILLEMETER"
|
|
60 PRINT "SIZE,YOU WILL BE ABLE TO DESTROY YOUR"
|
|
70 PRINT "OPPONANT. EACH OF YOU IN TURN WILL TAKE"
|
|
80 PRINT "A SHOT AT YOUR OPPONANT WHILE TAKING"
|
|
90 PRINT "INTO ACCOUNT THE WIND SPEED. YOU WILL"
|
|
100 PRINT "ENTER THE DEGREE MEASURE(BETWEEN"
|
|
110 PRINT "20 AND 100 DEGREES).THIS WILL BE
|
|
120 PRINT "FOLLOWED BY THE MILLIMETER SIZE(45 TO"
|
|
130 PRINT "150 MM)"
|
|
131 PRINT
|
|
132 PRINT " -HIT RETURN TO CONTINUE-"
|
|
140 GET LOST$
|
|
150 HGR
|
|
160 HCOLOR= 6
|
|
170 G(1) = RND (1) * 117 + 8
|
|
180 G(2) = RND (1) * 117 + 125
|
|
190 IF G(2) - G(1) < 140 THEN 170
|
|
200 W1 = INT ( RND (1) * 41)
|
|
210 W2 = INT ( RND (1) + .5) - 1
|
|
220 IF W2 < 0 THEN 240
|
|
230 W2 = 1
|
|
240 HPLOT G(2) + 8,149 TO G(2),145
|
|
250 X = 1
|
|
260 HPLOT G(X) - 8,149 TO G(X),145
|
|
270 HPLOT G(2) + 8,150 TO G(2),146
|
|
280 HPLOT G(X) - 8,150 TO G(X),146
|
|
290 HPLOT G(2) + 4,145 TO G(2) - 3,137
|
|
300 HPLOT G(X) - 4,145 TO G(X) + 3,137
|
|
310 HPLOT G(2) + 5,144 TO G(2) - 7,136
|
|
320 HPLOT G(X) - 5,144 TO G(X) + 7,136
|
|
330 HPLOT G(2) + 2,135 TO G(2) - 2,150
|
|
340 HPLOT G(X) - 2,135 TO G(X) + 2,150
|
|
350 P1 = W2
|
|
360 GOSUB 1440
|
|
370 GOSUB 1630
|
|
380 FOR X8 = 1 TO 20
|
|
390 P2 = 0
|
|
400 P1 = P1 * ( - 1)
|
|
410 GOSUB 1290
|
|
420 PRINT : PRINT : PRINT : GOSUB 1580
|
|
430 PRINT "ENTER DEGREE (20-100) & MM SIZE (45-150) TO DESTROY THE OPPOSING CANNON"
|
|
440 INPUT A1,V1
|
|
441 IF A1 > 100 OR A1 < 20 THEN 445
|
|
442 IF V1 > 150 OR V1 < 45 THEN 445
|
|
443 GOTO 450
|
|
445 PRINT "": INVERSE : PRINT "ILLEGAL QUANTITY-TRY AGAIN": NORMAL : GOTO 430
|
|
450 A1 = A1 * 3.1415926 / 180
|
|
460 X1 = COS (A1) * V1
|
|
470 Y1 = SIN (A1) * V1
|
|
480 T1 = Y1 / 16
|
|
490 T2 = T1 / 24
|
|
500 W3 = W1 * T2 * P1
|
|
510 W5 = 0
|
|
520 FOR Y8 = 0 TO T1 STEP T2
|
|
530 W5 = W5 + W3
|
|
540 X = X1 * Y8
|
|
550 X = X + (W5 * W2)
|
|
560 X = INT (X + .5)
|
|
570 Y = Y1 * Y8 - 16 * Y8 ^ 2
|
|
580 Y = INT (Y + .5)
|
|
590 IF Y < 9 THEN 750
|
|
600 IF P1 < 0 THEN 680
|
|
610 G4 = G(1) + X
|
|
620 IF G4 < 1 OR G4 > 254 THEN 670
|
|
630 IF Y > 149 THEN 670
|
|
640 HCOLOR= 5
|
|
650 HPLOT X2,Y2 TO G4,150 - Y
|
|
660 X2 = G4:Y2 = 150 - Y
|
|
670 GOTO 750
|
|
680 G4 = G(2) - X
|
|
690 IF G4 < 0 OR G4 > 254 THEN 750
|
|
700 IF Y > 149 THEN 750
|
|
710 HCOLOR= 3
|
|
720 HPLOT X2,Y2 TO G4,150 - Y
|
|
730 X2 = G4:Y2 = 150 - Y
|
|
740 IF Y8 = 0 THEN 770
|
|
750 GOSUB 1060
|
|
760 IF P2 = 5 THEN 800
|
|
770 NEXT Y8
|
|
780 Y6 = 150
|
|
790 GOSUB 1160
|
|
800 IF G4 > G(1) + 5 OR G4 < G(1) - 5 THEN 850
|
|
810 PRINT : PRINT : PRINT
|
|
820 PRINT "GOOD WORK! RIGHT GUN SURVIVES."
|
|
830 T3 = T3 + 1
|
|
840 GOTO 930
|
|
850 IF G4 > G(2) + 5 OR G4 < G(2) - 5 THEN 900
|
|
860 PRINT : PRINT : PRINT
|
|
870 PRINT "NICE SHOOTING! LEFT GUN SURVIVES."
|
|
880 T4 = T4 + 1
|
|
890 GOTO 930
|
|
900 P2 = 0
|
|
910 G4 = 0
|
|
920 NEXT X8
|
|
930 PRINT : PRINT "DO YOU WANT TO PLAY AGAIN";
|
|
940 INPUT A$
|
|
950 IF A$ = "Y" THEN 150
|
|
951 IF A$ = "YES" THEN 150
|
|
960 HGR
|
|
970 TEXT
|
|
980 HOME
|
|
990 PRINT "SCORE"
|
|
1000 PRINT "-----"
|
|
1010 PRINT "LEFT ";T4
|
|
1020 PRINT "RIGHT ";T3
|
|
1045 D9$ = "CHR$(13)": PRINT D$
|
|
1050 END
|
|
1060 Y6 = 150
|
|
1070 G8 = Y7 + 2 * G3
|
|
1080 Y7 = G(1) + G2
|
|
1090 IF Y > G3 THEN 1280
|
|
1100 IF G4 < Y7 + Y THEN 1280
|
|
1110 IF G4 > G8 - Y THEN 1280
|
|
1120 P2 = 5
|
|
1130 P2 = 5
|
|
1140 Y6 = 150 - Y
|
|
1150 Y6 = 150 - Y
|
|
1160 FOR Z = 1 TO 5
|
|
1170 IF G4 < 0 OR G4 > 253 THEN 1240
|
|
1180 HPLOT G4,Y6 - Z
|
|
1190 HPLOT G4 + Z,Y6 - Z
|
|
1200 HPLOT G4 - Z,Y6 - Z
|
|
1210 HPLOT G4 + Z,Y6 - 1
|
|
1220 HPLOT G4 - Z,Y6 - 1
|
|
1230 X5 = PEEK ( - 16336)
|
|
1240 NEXT Z
|
|
1250 Y = 0
|
|
1260 X = 0
|
|
1270 GOSUB 1630
|
|
1280 RETURN
|
|
1290 IF P1 < 0 THEN 1360
|
|
1300 HPLOT 1,152 TO 4,152
|
|
1310 HPLOT 1,153 TO 4,153
|
|
1320 HPLOT 1,154 TO 4,154
|
|
1330 HPLOT 1,155 TO 4,155
|
|
1340 IF P1 < 0 THEN 1420
|
|
1350 HCOLOR= 0
|
|
1360 HPLOT 250,152 TO 254,152
|
|
1370 HPLOT 250,153 TO 254,153
|
|
1380 HPLOT 250,154 TO 254,154
|
|
1390 HPLOT 250,155 TO 254,155
|
|
1400 HCOLOR= 0
|
|
1410 IF P1 < 0 THEN 1300
|
|
1420 HCOLOR= 2
|
|
1430 RETURN
|
|
1440 G1 = (G(2) - G(1)) / 2
|
|
1450 G2 = RND (1) * (G1 - 1) + 1
|
|
1460 G3 = RND (1) * G1 / 2 + 10
|
|
1470 IF G3 < 30 THEN 1460
|
|
1480 IF G(2) - (G(1) + G2) > 2 * G3 THEN 1510
|
|
1490 G3 = G3 - 1
|
|
1500 GOTO 1480
|
|
1510 FOR M1 = 1 TO 252
|
|
1520 HCOLOR= 1
|
|
1530 HPLOT M1,150
|
|
1540 NEXT M1
|
|
1550 HPLOT G(1) + G2,150 TO G(1) + G2 + G3,150 - G3
|
|
1560 HPLOT G(1) + G2 + 2 * G3,150 TO G(1) + G2 + G3,150 - G3
|
|
1570 RETURN
|
|
1580 IF W2 < 0 THEN 1610
|
|
1590 PRINT "THE WIND IS TO THE RIGHT AT ";W1
|
|
1600 GOTO 1620
|
|
1610 PRINT "THE WIND IS TO THE LEFT AT ";W1
|
|
1620 RETURN
|
|
1630 IF P1 < 0 THEN 1660
|
|
1640 X2 = G(2):Y2 = 150
|
|
1650 GOTO 1670
|
|
1660 X2 = G(1):Y2 = 150
|
|
1670 RETURN
|