home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols100 / vol142 / spacewar.bas < prev    next >
Encoding:
BASIC Source File  |  1984-04-29  |  10.4 KB  |  212 lines

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