March 12, 2017

Apple ][ - Artillery

Another great game that we enjoyed on the Apple ][ computer as kinds was Artillery (game_01a.dsk). Artillery was a ancestor of the now ancient shareware game Scorch (Scorched Earth), probably the first in turn based artillery genre. Artillery used basic math to pit two forces against each other. There was a mountain in between the two 'castles,' and the castles took turns shooting rounds at each other. There was a random variable to each game, the wind. After a while, you became good at predicting the best angle and velocity to put into your round, but the wind always meant that there was and element of learning.


I loved this game, and before we finally donated our ancient IIgs, I printed off the source code for it (via dot matix). Although it did not matter as much of what was popular is archived online. Artillery the program was programmed in Apple Basic; the source code for Artillery was a paltry 175 lines (including 34 lines of remarks/metadata information):



 1  REM    ARTILLERY 10/1/80 
 2  REM   
 3  REM    GAME - LOGIC AND
 4  REM    ANGLE MEASUREMENT
 5  REM 
 6  REM    APPLESOFT,COLOR,4K
 7  REM   
 8  REM    ADAPTED BY B. GOODSON
 9  REM   
 10  REM   FROM USER'S GROUP LIB
 11  REM        
 12  REM ***********************
 13  REM *                     *
 14  REM *  SAN MATEO COUNTY   *
 15  REM * OFFICE OF EDUCATION *
 16  REM *                     *
 17  REM *   COMPUTER-USING    *
 18  REM *      EDUCATORS      *
 19  REM *                     *
 20  REM *      SOFTSWAP       *
 21  REM *                     *
 22  REM *   333 MAIN STREET   *
 23  REM *     REDWOOD CITY    *
 24  REM *       CA 94063      *
 25  REM *(415)364-5600 EX 4401*
 26  REM *                     *
 27  REM ***********************
 28  REM *
 29  REM ***********************
 30  REM *PROGRAM MAY BE COPIED*
 31  REM *FOR EDUCATIONAL USE  *
 32  REM *ONLY AND IS NOT TO BE*
 33  REM *SOLD.                *
 34  REM ***********************
 46  TEXT : CALL  - 936: VTAB 5: PRINT 
      TAB( 7)"*** ARTILLERY SIMUL
     ATOR ***"
 47  GOSUB 300
 50  VTAB 24: PRINT "PRESS 'SPACE
      BAR' TO CONTINUE...";: GET 
     SX$
 51  DIM YY(280)
 52 P1 = 99
 53 PI = 3.141592654 / 180
 54  HGR 
 55  CALL  - 936
 56 P1 =  - P1
 57  HCOLOR= 1
 60 P =  RND (1) * 20 + 139
 61  FOR I = 1 TO 112: HPLOT I,P TO 
     I,159:YY(I) = P: NEXT 
 62 HG =  RND (1) * 50 + 25
 63  FOR I = 113 TO 152:HX =  SIN 
     (((I - 112) * 4.5 + 180) * P
     I) * HG
 64 YY(I) = HX + P
 65  HPLOT I,HX + P TO I,159: NEXT 
     
 66  FOR I = 153 TO 279: HPLOT I,
     P TO I,159:YY(I) = P: NEXT 
 67 WIND =  INT ( RND (1) * 10): IF 
      RND (1) * 100 > 50 THEN WIN
     D =  - WIND
 70  HCOLOR= 3: HPLOT 112,10 TO 1
     52,10
 71  IF WIND > 0 THEN  HPLOT 112,
     10 TO 125,5
 72  VTAB 21: PRINT  TAB( 17)"WIN
     D:"; ABS (WIND)
 73  IF WIND < 0 THEN  HPLOT 152,
     10 TO 139,5
 74 B1 =  RND (1) * 20 + 50 - 5 * 
     WIND:B2 =  RND (1) * 20 + 20
     0 + WIND * 5
 75  HPLOT B1 - 3,P TO B1 - 3,P - 
     5: HPLOT  TO B1 + 3,P - 5: HPLOT 
      TO B1 + 3,P: HPLOT  TO B1 - 
     3,P - 5: HPLOT B1 - 3,P TO B
     1 + 3,P - 5
 76  HCOLOR= 2: HPLOT B2 - 3,P TO 
     B2 - 3,P - 5: HPLOT  TO B2 + 
     3,P - 5: HPLOT  TO B2 + 3,P:
      HPLOT  TO B2 - 3,P - 5: HPLOT 
     B2 - 3,P TO B2 + 3,P - 5
 77  IF P1 = 99 THEN 120
 80  VTAB 24: INPUT "ANG,FORCE?";
     AN,BG:BG = BG * 10
 81  IF P1 =  - 99 THEN PX = B1
 82  IF P1 = 99 THEN PX = B2
 83  VTAB 21: PRINT  TAB( 17)"WIN
     D:"; ABS (WIND)
 84 I = 0
 85 I = I + .1:X = BG * I *  COS 
     (AN * PI)
 86  IF P1 =  - 99 THEN X = X + B
     1
 87 K =  PEEK ( - 16336): POKE  - 
     16336,0
 90  IF P1 = 99 THEN X = B2 + X
 91 Y = BG * I *  SIN (AN * PI) - 
     16 * I ^ 2
 92 X = X - WIND * I ^ 2
 93  IF P1 = 99 THEN Y = BG * I * 
     ( -  SIN (AN * PI)) - 16 * I
      ^ 2
 94  HCOLOR= 0: HPLOT PX,PY
 95  IF X < 3 OR X > 276 OR P - Y
      < 0 THEN 115
 96  IF YY(X) < P - Y THEN 100
 97  HCOLOR= 3: HPLOT X,P - Y
 98 PX = X:PY = P - Y
 99  GOTO 85
 100  IF  ABS (X - B1) < 3 THEN 2
     00
 101  IF  ABS (X - B2) < 3 THEN 2
     10
 105  IF X < 3 OR X > 276 THEN 11
     5
 108  HCOLOR= 0: FOR I = 1 TO 25:
     BX = X - 3 +  RND (1) * 6:BY
      = YY(BX) +  RND (1) * 3: HPLOT 
     BX,BY
 110 K =  PEEK ( - 16336): POKE  - 
     16336,0: NEXT 
 112  FOR I = X - 3 TO X + 3:YY(I
     ) = YY(I) + 3: NEXT 
 115 P1 =  - P1: IF P1 =  - 99 THEN 
     80
 120  VTAB 24: PRINT  TAB( 25);: INPUT 
     "ANG,FORCE?";AN,BG:BG = BG * 
     10
 130 AN = AN + 180
 135 PY = P - 5
 140  GOTO 81
 200 GX = B1: GOTO 220
 210 GX = B2
 220  HCOLOR= 3: FOR I = GX - 10 TO 
     GX + 10 STEP 2: HPLOT I,P - 
     10 TO GX,P: FOR J = 1 TO  RND 
     (1) * 5 + 5:K = K +  PEEK ( - 
     16336): NEXT : POKE  - 16336
     ,0: NEXT 
 230  FOR I = 1 TO 2500: NEXT 
 240  PRINT : PRINT : PRINT : PRINT 
     
 250  INPUT "DO YOU WANT TO PLAY 
     AGAIN? ";Z$
 255  IF  LEFT$ (Z$,1) = "Y" THEN 
      RUN 
 257  POKE  - 16300,0: POKE  - 16
     298,0: TEXT : HOME 
 260  END 
 300  VTAB 8: PRINT "HOW GOOD ARE
      YOU AT ESTIMATING ANGLES?"
 305  PRINT : PRINT "IN THIS GAME
      YOU MUST "
 310  PRINT "     1)ESTIMATE THE 
     BEST ANGLE AND"
 315  PRINT "     2)FIND THE NECE
     SSARY FORCE"
 320  PRINT "TO HIT THE TARGET BE
     HIND THE MOUNTAIN."
 325  PRINT : PRINT "YOU MUST CON
     SIDER THE EFFECT OF THE     
     WIND SPEED AND DIRECTION ON 
     YOUR SHOT."
 330  PRINT : PRINT "WHEN IT IS Y
     OUR TURN, ENTER THE ANGLE,  
     COMMA, AND THE FORCE YOU WAN
     T TO TRY."
 335  PRINT : PRINT "    EXAMPLE:
      ANG,FORCE"
 340  PRINT "             70.1,8.
     5"
 350  RETURN 

No comments: