home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol142 / kpro2-sw.bas < prev    next >
Encoding:
BASIC Source File  |  1984-04-29  |  9.4 KB  |  195 lines

  1. 10 ' SPACEWAR - Complements of the Wizard of OsZ, and Kelly Smith CP/M-Net
  2. 20 ' ------------------ Kaypro II Terminal Commands ----------------------
  3. 30 '
  4. 40 E$=CHR$(27):'                Escape Character
  5. 50 CLS$=CHR$(26):'              Clear Screen
  6. 60 DC$=E$+"=":'                 Direct Cursor Addressing
  7. 70 EP$=E$+"T":'                Erase to End of Line
  8. 80 'NOTE: The Kaypro II uses the following scheme for direct cursor addressing:
  9. 90 '       Location= (CHR$(Line number+32));(CHR$(Column number+32))
  10. 100 'It appears that the Kaypro II looks very much like an ADM-3A Terminal !!!
  11. 110 '
  12. 120 PRINT CLS$
  13. 130 PRINT"           The Wizard of OsZ - 'SPACEWAR'"
  14. 140 PRINT
  15. 150 PRINT:PRINT "Do you require instructions (Y or N) ?";
  16. 160 A$=INKEY$:IF LEN(A$)=0 THEN GOTO 160 ' get keyboard input
  17. 170 IF A$="N" OR A$="n" THEN PRINT CLS$:GOTO 480
  18. 180 PRINT CLS$ ' clear screen
  19. 190 PRINT "You  are  about to go on a mission to  destroy  five" 
  20. 200 PRINT "alien  space  craft  that threaten  the  galaxy...In" 
  21. 210 PRINT "order  to  destroy an alien space  craft,  you  must" 
  22. 220 PRINT "position it such that it appears in the exact center" 
  23. 230 PRINT "of your target sight.   To do that,  use the numeric" 
  24. 240 PRINT "keypad  to position the alien craft in the following" 
  25. 250 PRINT "four directions:"
  26. 260 PRINT
  27. 270 FOR I=1 TO 10:PRINT DC$+CHR$(41)+CHR$(32);EP$
  28. 280 FOR N=1 TO 10:NEXT N ' ring bell and flash message on screen
  29. 290 PRINT CHR$(7);DC$+CHR$(41)+CHR$(32);
  30.  
  31.     "        8 - Up, 2 - Down, 4 - Left, 6 - Right";
  32. 300 FOR N=1 TO 10:NEXT N
  33. 310 NEXT I
  34. 320 FOR N=1 TO 2000:NEXT N:PRINT:PRINT
  35. 330 FOR I=1 TO 10:PRINT DC$+CHR$(43)+CHR$(32);EP$
  36. 340 FOR N=1 TO 10:NEXT N ' ring bell and flash message on screen
  37. 350 PRINT CHR$(7);DC$+CHR$(43)+CHR$(32);
  38.  
  39.     "Then  to fire on the alien space craft,  enter  '5'.";
  40. 360 FOR N=1 TO 10:NEXT N
  41. 370 NEXT I
  42. 380 FOR N=1 TO 2000:NEXT N:PRINT:PRINT
  43. 390 PRINT DY$"Also,   time   is  an  important  factor   on   your" 
  44. 400 PRINT "mission...Alien  return  fire degrades  your  target" 
  45. 410 PRINT "aiming ability, so don't delay!  Your performance is" 
  46. 420 PRINT "based  on the number of alien space craft  destroyed" 
  47. 430 PRINT "to  the number of misses...";"Enter '0' at any time  to" 
  48. 440 PRINT "quit";".   Please  enter  you  current  rating  now  as" 
  49. 450 PRINT "follows:"
  50. 460 PRINT DN$
  51. 470 FOR N=1 TO 2000:NEXT N
  52. 480 FOR I=1 TO 10:PRINT DC$+CHR$(53)+CHR$(32);EP$
  53. 490 FOR N=1 TO 10:NEXT N ' ring bell and flash message on screen
  54. 500 PRINT CHR$(7);DC$+CHR$(53)+CHR$(35);
  55.  
  56.     "N - Novice, H - Hotshot, E - Expert, A - Ace ?";
  57. 510 FOR N=1 TO 10:NEXT N
  58. 520 NEXT I
  59. 530 V$=INKEY$:IF LEN(V$)=0 THEN GOTO 530 ' get keyboard input and create rating value
  60. 540 IF V$="N" OR V$="n" THEN V=100 ' novice rating
  61. 550 IF V$="H" OR V$="h" THEN V=50 ' hotshot rating
  62. 560 IF V$="E" OR V$="e" THEN V=10 ' expert rating
  63. 570 IF V$="A" OR V$="a" THEN V=5 ' ace, and you better be fast on this one!
  64. 580 PRINT CLS$ ' clear screen
  65. 590 FOR I=1 TO 10:PRINT DC$+CHR$(44)+CHR$(32);EP$
  66. 600 FOR N=1 TO 30:NEXT N ' ring bell and flash message on screen
  67. 610 PRINT CHR$(7);DC$+CHR$(44)+CHR$(43);"Good luck on your mission !!!";
  68. 620 FOR N=1 TO 30:NEXT N
  69. 630 NEXT I
  70. 640 D=1:D1=1:PRINT CLS$ ' clear screen
  71. 650 GOSUB 1770 ' display initial pilot rating
  72. 660 Y=6:X=0:GOSUB 1100:GOSUB 930 ' display cross-hairs
  73. 670 Y=2:X=14:GOSUB 1100:PRINT "Target Position: "
  74. 680 Y=INT(10*RND(1)+7) ' set y axis random bounds
  75. 690 X=INT(20*RND(1)+21) ' set x axis random bounds
  76. 700 GOSUB 1100 ' position to xy coordinate
  77. 710 GOSUB 1070 ' display target
  78. 720 GOSUB 1660 ' advance alien target position
  79. 730 P=Y:Q=X:Y=2:X=31:GOSUB 1100 ' save xy position, position next message
  80. 740 PRINT "X =";Q-25;"Y =";P-12 ' display alien target coordinates
  81. 750 Y=3:X=13:GOSUB 1100:PRINT "Time =";R;:R=R+1 ' display relative run time
  82. 760 D2=SQR(((P-12)^2)+((Q-25)^2)) ' compute distance to target
  83. 770 Y=3:X=25:GOSUB 1100:PRINT "Distance =";D2;EP$ ' display distance to target
  84. 780 Y=P:X=Q ' restore original xy coordinate values
  85. 790 A$=INKEY$:IF LEN(A$)=0 THEN GOTO 720 ' check for keyboard input
  86. 800 GOSUB 1100 ' position to xy coordinate
  87. 810 IF A$="6" OR A$=CHR$(12) THEN X=X+1 ' 6 or RIGHT arrow = move right
  88. 820 IF A$="4" OR A$=CHR$(8) THEN X=X-1 ' 4 or LEFT arrow = move left
  89. 830 IF A$="2" OR A$=CHR$(10) THEN Y=Y+1 ' 2 or DOWN arrow = move down
  90. 840 IF A$="8" OR A$=CHR$(11) THEN Y=Y-1 ' 8 or UP arrow = move up
  91. 850 IF A$="5" OR A$="*" THEN GOTO 1120 ' 5 or RETURN = fire on target
  92. 860 IF A$="0" THEN PRINT CLS$:GOTO 1540 ' 0 = quit (maybe)
  93. 870 IF A$="1" OR A$="3" OR A$="7" OR A$="9" THEN GOSUB 1840 ' re-display '+'
  94. 880 IF A$="." THEN GOSUB 1860 ' momentarily display total score if '.' pressed
  95. 890 GOSUB 1630 ' erase target position
  96. 900 GOSUB 1100 ' position to xy coordinate
  97. 910 GOSUB 1070 ' display target
  98. 920 GOTO 720 ' repeat erase/move/position/display sequence
  99. 930 PRINT "                -----------------------" ' cross-hairs
  100. 940 PRINT "                           |"
  101. 950 PRINT "                           |"   
  102. 960 PRINT "                           |"
  103. 970 PRINT " |                                                   |"
  104. 980 PRINT " |                |                 |                |" 
  105. 990 PRINT " |----------------|        +        |----------------|"    
  106. 1000 PRINT " |                |                 |                |"
  107. 1010 PRINT " |                                                   |"
  108. 1020 PRINT " |                         |                         |"
  109. 1030 PRINT "                           |"
  110. 1040 PRINT "                           |"
  111. 1050 PRINT "                -----------------------"
  112. 1060 RETURN
  113. 1070 PRINT"<-*->": ' target display
  114. 1080 P=Y:Q=X ' save xy position
  115. 1090 RETURN
  116. 1100 PRINT DC$+CHR$(32+Y)+CHR$(32+X); ' position to xy coordinate
  117. 1110 RETURN
  118. 1120 IF Y=12 THEN GOTO 1140 ' proper line for hit on target?
  119. 1130 GOSUB 1430:GOTO 700 ' no, show total number missed
  120. 1140 IF X=25 THEN GOTO 1160 ' proper column for hit on target?
  121. 1150 GOSUB 1430:GOTO 700 ' no, show total number missed
  122. 1160 Y=12:X=26:GOSUB 1100:PRINT "*";"+";"*" ' explosion
  123. 1170 Y=11:X=27:GOSUB 1100:PRINT "*"
  124. 1180 Y=13:X=27:GOSUB 1100:PRINT "*" ' a quick puff of smoke...
  125. 1190 Y=12:X=25:GOSUB 1100:PRINT "+ + +"
  126. 1200 Y=11:X=26:GOSUB 1100:PRINT "+ +"
  127. 1210 Y=13:X=26:GOSUB 1100:PRINT "+ +"
  128. 1220 Y=10:X=27:GOSUB 1100:PRINT "+"
  129. 1230 Y=14:X=27:GOSUB 1100:PRINT "+" ' alien craft coming unglued...
  130. 1240 Y=12:X=25:GOSUB 1100:PRINT " "
  131. 1250 Y=11:X=28:GOSUB 1100:PRINT " "
  132. 1260 Y=10:X=27:GOSUB 1100:PRINT " "
  133. 1270 Y=13:X=26:GOSUB 1100:PRINT " "
  134. 1280 Y=12:X=29:GOSUB 1100:PRINT " "
  135. 1290 Y=13:X=28:GOSUB 1100:PRINT " "
  136. 1300 Y=14:X=27:GOSUB 1100:PRINT " "
  137. 1310 Y=12:X=27:GOSUB 1100:PRINT " "
  138. 1320 Y=11:X=26:GOSUB 1100:PRINT " " ' alien craft destroyed (totally!)
  139. 1330 FOR I=1 TO 10:PRINT DC$+CHR$(54)+CHR$(32);EP$
  140. 1340 FOR N=1 TO 50:NEXT N ' ring bell and flash message on screen
  141. 1350 PRINT CHR$(7);DC$+CHR$(54)+CHR$(37);
  142.  
  143.      "M A Y  T H E  F O R C E  B E  W I T H  Y O U";
  144. 1360 FOR N=1 TO 50:NEXT N
  145. 1370 NEXT I:PRINT DC$+CHR$(54)+CHR$(32);EP$ 
  146. 1380 S=S+10:GOSUB 1860 ' add 10 to total score, and display total score
  147. 1390 Y=20:X=17:GOSUB 1100 ' position cursor for next message
  148. 1400 PRINT "Aliens Destroyed =";D1 ' add 1 to alien craft hit
  149. 1410 D1=D1+1:IF D1=6 THEN 1480 ' close up shop if all 5 destroyed
  150. 1420 GOTO 680 ' continue with next target
  151. 1430 S=S-10:GOSUB 1860 ' subtract 10 from total score, and display total score
  152. 1440 P=Y:Q=X:Y=21:X=17:GOSUB 1100 ' position cursor for next message
  153. 1450 PRINT "Aliens Missed =";D:D=D+1 ' add 1 to alien craft missed
  154. 1460 Y=P:X=Q:GOSUB 1100 ' position to xy coordinate
  155. 1470 RETURN
  156. 1480 Y=20:X=0:GOSUB 1100 ' position to xy coordinate
  157. 1490 D=D-1 ' subtract -1 to number missed
  158. 1500 PRINT "    Congratulations, You have saved the galaxy !!!"
  159. 1510 PRINT "        Your mission record:";INT(5/(5+D)*100);"% performance"
  160. 1520 IF 5/(5+D)*100>75 THEN V=V-50
  161. 1530 IF 5/(5+D)*100<51 THEN V=V+50
  162. 1540 Y=21:X=7:GOSUB 1100
  163. 1550 PRINT DC$+CHR$(54)+CHR$(32);EP$
  164. 1560 FOR N=1 TO 100:NEXT N ' ring bell and flash message on screen
  165. 1570 PRINT CLS$;DC$+CHR$(54)+CHR$(40);"Do you want another mission (Y or N) ?"
  166. 1580 FOR N=1 TO 100:NEXT N
  167. 1590 A$=INKEY$:IF LEN(A$)=0 THEN GOTO 1550
  168. 1600 PRINT DC$+CHR$(54)+CHR$(32);EP$ 
  169. 1610 IF LEFT$(A$,1)="Y" OR LEFT$(A$,1)="y" THEN PRINT CLS$:GOTO 480
  170. 1620 PRINT CLS$:SYSTEM
  171. 1630 PRINT DC$+CHR$(32+P)+CHR$(32+Q); ' position cursor to target location
  172. 1640 PRINT "     " ' erase target location
  173. 1650 RETURN
  174. 1660 T=T+1.5 ' overall skill level set here (3 is super skill level!)
  175. 1670 IF T>V THEN 1690
  176. 1680 RETURN
  177. 1690 IF X>36 THEN GOTO 1730
  178. 1700 IF Y<12 THEN GOTO 1730
  179. 1710 X=X+1:Y=Y-1:GOSUB 1630:GOSUB 1100:GOSUB 1070:GOTO 1740
  180. 1720 GOTO 1740
  181. 1730 X=X+1:Y=Y-1:GOSUB 1630:GOSUB 1100:GOSUB 1070:GOTO 1740
  182. 1740 IF X>45 OR X<1 THEN Y=12:X=19:V=V+10:GOSUB 1100:
  183.  
  184.      PRINT CHR$(7);"You're shot down!":GOSUB 1830:GOTO 1540
  185. 1750 IF Y<7 OR Y>18 THEN Y=12:X=19:V=V+10:GOSUB 1100:
  186.  
  187.      PRINT CHR$(7);"You're destroyed!":GOSUB 1830:GOTO 1540
  188. 1760 T=0:RETURN
  189. 1770 IF V<=5 THEN Q$="Rating = Ace Pilot":GOTO 1810 ' determine pilot rating
  190. 1780 IF V<=10 THEN Q$="Rating = Expert Pilot":GOTO 1810
  191. 1790 IF V<=49 THEN Q$="Rating = Hotshot Pilot":GOTO 1810
  192. 1800 Q$="Rating = Novice Pilot"
  193. 1810 Y=0:X=17:GOSUB 1100 ' set cursor position for pilot rating
  194. 1820 PRINT Q$:RETURN ' print rating
  195. 1830 FOR N=1 TO 300:NEXT N:RETURN ' general purpose delay
  196. 1840 P=Y:Q=X:Y=12:X=27:GOSUB 1100:PRINT "+" ' print '+' for digits 1,3,7,9
  197. 1850 Y=P:X=Q:RETURN
  198. 1860 P=Y:Q=X:Y=12:X=19:GOSUB 1100:PRINT "Total Score =";S ' display total score
  199. 1870 GOSUB 1830:GOSUB 1830:GOSUB 1100 ' delay while score is displayed
  200. 1880 PRINT "        +        ":Y=P:X=Q:RETURN ' erase score display and return
  201.