home *** CD-ROM | disk | FTP | other *** search
/ Merciful 3 / Merciful_Release_3.bin / software / s / skeetshoot.dms / skeetshoot.adf / skeet_shooting.amos / skeet_shooting.amosSourceCode < prev    next >
AMOS Source Code  |  1978-10-14  |  12KB  |  308 lines

  1. '***************************************************************************** 
  2. '*                                                                           * 
  3. '*     SKEET AND TARGET SHOOTING BY STEVE BENNETT. WRITTEN IN JANUARY 91     *     
  4. '*                                                                           * 
  5. '***************************************************************************** 
  6. '* This is a simple shooting game that I have done to show beginners to AMOS *   
  7. '* basic the sort of thing that can be produced in a few hundred lines of    * 
  8. '* code. I have tried to make the code as easy to understand as possible by  *   
  9. '* making the routines as long and as simple as I can. Certain areas may not * 
  10. '* be that easy to understand at first, but as you learn, all will become    * 
  11. '* clear. I have left the program unfinished to allow you to add whatever    *     
  12. '* you want. High score table. Better graphics. More sections. Etc.          *   
  13. '* As a bit of advice, you should go through the program with - FOLLOW -.    *   
  14. '* This will allow you to step through the program and see, to some extent   *     
  15. '* what each line does.                                                      *   
  16. '*                                                                           *   
  17. '* Ok game play. On the skeet shooting section  you are given 20 shots.      *   
  18. '* Skeets are fired at random 1, or 2 at once. The left mouse button fires   * 
  19. '* the left barrel. The right mouse button fires the right barrel. You may   * 
  20. '* fire 1 or both barrels if one skeet is fired, but you must fire both      * 
  21. '* barrels if two skeets are fired. The gun will then reload. After the      * 
  22. '* skeet section we go onto the target shooting. Again you are given 20      * 
  23. '* shots. You must fire BOTH barrels at each target. A large target in the   * 
  24. '* right hand corner will display where it was hit or missed. As you shoot   * 
  25. '* the gun will kick up as a real one would. You are not allowed to move the * 
  26. '* sights from the bottom of the screen until a skeet or target have been    * 
  27. '* fired/setup.                                                              * 
  28. '*                                                                           * 
  29. '* As I said. You may alter the program how you wish, and pass on copies     * 
  30. '* to your friends. But please do not pirate my bobtoolbox program. I have   *   
  31. '* put a lot of work into it, for your benefit and will be upgrading it      * 
  32. '* during the year.                                                          *   
  33. '*                         Many Thanks. Steve Bennett.                       *     
  34. '*                                                                           * 
  35. '*  PLEASE CONTINUE TO SUPPORT THE AMOS PD LIBRARY AND JOIN THE USER GROUP   *   
  36. '*                                                                           * 
  37. '*    Oh! must say hi to my good buddy gaz shilvock who has been mentioned   * 
  38. '* in aprils amiga format for his mandelbrot generator. Its available from   * 
  39. '* sandra/pd library. What it is to be famous eh!.                           *   
  40. '***************************************************************************** 
  41. '
  42. 'Follow :rem *** USE THIS LINE TO FOLLOW THE PROGRAM THROUGH ***   
  43. Unpack 10 To 0 : Rem    *** get the background picture from bank 10 ***   
  44. Double Buffer : Rem     *** used to stop bobs flickering on the screen *** 
  45. Get Sprite Palette : Rem ** use the colurs of the sprites for the screen ***
  46. Paper 0 : Pen 1 : Rem   *** set the background colour to black. front to white *** 
  47. Change Mouse 2 : Rem    *** change the mouse to a crosshair *** 
  48. Limit Mouse 143,58 To 435,273 : Rem *** stop the mouse going off the screen ***
  49. X Mouse=289 : Y Mouse=273 : Rem *** position the mouse 289 across - 273 down *** 
  50. '********* set amal channel to control - gun to mouse movement ***************** 
  51. GUN$="AUtest(If R0<>XM Jump Update"
  52. GUN$=GUN$+"If R1<>YM Jump Update else eXit"
  53. GUN$=GUN$+"Update: Let R0=XM-158 ; Let R1=YM+27 ; Direct M)"
  54. GUN$=GUN$+"M: If YM>204 Jump Out else Jump N ; Out: Let X=R0 ; Let Y=230"
  55. GUN$=GUN$+"N: If YM<127 Jump S else Jump R ; S: Let X=R0 ; Let Y=151"
  56. GUN$=GUN$+"R: Let R2=YM>127 ; Let R3=YM<204 ; If R2&R3 Jump Q else Wait ; Q: Let X=R0 ; Let Y=R1 ; Wait "
  57. Channel 1 To Bob 1
  58. Bob 1,131,230,1 : Rem *** position bob 1 on screen as a gun - image 1 ***  
  59. Amal 1,GUN$
  60. Amal On 1
  61. Channel 3 To Bob 3
  62. '************ set animation for skeets and movement ***********  
  63. SKEET1$="A 1,(7,10)(8,10)(9,10)(10,10)(11,5)(12,5) ; PL Z(5)+1 ; M 100,50,50 ;  End"
  64. Channel 4 To Bob 4
  65. SKEET2$="A 1,(7,10)(8,10)(9,10)(10,10)(11,5)(12,5) ; PL Z(5)+7 ; M -100,50,50 ; End"
  66. TARGET$="Let A=15 ; Let Y=165 ; M 0,-15,30 ; For R0=0 To 50 ; Next R0 ; M 0,15,30 ; End"
  67. '
  68. SKEETS=0 : Rem *** number of skeets fired *** 
  69. SHOTS=0 : Rem  *** number of shots fired *** 
  70. HITS=0 : Rem   *** how many hits ***
  71. MISSES=0 : Rem *** how many misses ***  
  72. SCORE=0 : Rem  *** what your score *** 
  73. DESTROYED=0 : Rem *** how many skeets destroyed ***
  74. LEVEL=1 : Rem *** start at level 1 - skeet shooting ***
  75. Screen Open 1,640,16,4,Hires : Rem *** open info screen for score etc. ***  
  76. Screen Display 1,,42,,8 : Rem *** position info screen at top of display *** 
  77. Paper 1 : Pen 2
  78. Print "   SKEETS ";SKEETS; : Print "      SHOTS ";SHOTS; : Print "       HITS ";HITS; : Print "       MISSES ";MISSES; : Print "       SCORE ";SCORE
  79. Screen 0 : Rem *** set screen to work in ***
  80. Auto View On : Rem *** allow screen changes to be seen ***
  81. LEFTBARREL=1 : RIGHTBARREL=1 : Rem *** left/right barrel loaded *** 
  82. '
  83. '************* main skeet shooting routine ********************* 
  84. Repeat 
  85.    '
  86.    If(Chanmv(3)=0) and(Chanmv(4)=0) Then Gosub SKEETFIRE
  87.    '
  88.    If Y Mouse>204 Then Colour 2,$FFF : Else Colour 2,$F
  89.    '
  90.    KEY=Mouse Key
  91.    '
  92.    If(KEY=1) and(LEFTBARREL=1) : Rem *** if button pressed and left barrel full *** 
  93.       Bob 2,X Mouse-138,Y Mouse-52,18 : Rem *** put bullet on screen *** 
  94.       Y Mouse=Y Mouse-10 : Rem *** make mouse jump ***
  95.       Sam Play 1,2 : Rem *** make shot sound ***
  96.       For T=3 To 4 : Rem *** check if skeet hit. If so add 10 to score ***
  97.          If Bob Col(T,2 To 2) : Bob T,X Bob(T)-5,Y Bob(T)-5,13 : Amal Off T
  98.             Add SCORE,10
  99.             Wait 2 : Bob Off 2 : Wait 10 : Bob Off T : HIT=1
  100.       End If : Next T
  101.       LEFTBARREL=0 : Rem *** left barrel empty ***
  102.       Inc SHOTS : Rem *** add 1 to number of shots fired *** 
  103.       If HIT=1 : Rem ***if skeet hit add 1 to hits and 1 to number destroyed ***
  104.          Inc HITS : HIT=0 : Inc DESTROYED
  105.       Else Inc MISSES : Rem *** if not hit add 1 to number of misses *** 
  106.       End If 
  107.       Wait 2 : Rem *** wait 2 vertical blanks to slow the program down ***
  108.       Bob Off 2 : Rem *** turn off bullet bob ***
  109.    End If 
  110.    '
  111. '********* now do the same tests for the right barrel *****************  
  112. If(KEY=2) and(RIGHTBARREL=1)
  113.       Bob 2,X Mouse-138,Y Mouse-52,18
  114.       Sam Play 2,2
  115.       Y Mouse=Y Mouse-10
  116.       For T=3 To 4
  117.          If Bob Col(T,2 To 2) : Bob T,X Bob(T)-5,Y Bob(T)-5,13 : Amal Off T
  118.             Add SCORE,10
  119.             Wait 2 : Bob Off 2 : Wait 10 : Bob Off T : HIT=1
  120.       End If : Next T
  121.       RIGHTBARREL=0
  122.       Inc SHOTS
  123.       If HIT=1
  124.          Inc HITS : HIT=0 : Inc DESTROYED
  125.       Else Inc MISSES
  126.       End If 
  127.       Wait 2
  128.       Bob Off 2
  129.    End If 
  130.    '
  131.    If(LEFTBARREL=0) and(RIGHTBARREL=0) : Rem *** if both barrels empty **** 
  132.       If(DESTROYED=2) and(WHICHHUT=3) : Add SCORE,100 : Sam Play 3,1
  133.          Screen 1 : Print "                              BONUS  100  POINTS"
  134.          Wait 50 : Screen 0
  135.       End If : Rem *** if both skeets hit. cheer sound. add 100 to score. *** 
  136.       Wait 20
  137.       Gosub RELOAD : Rem *** goto reload routine at the bottom of the program *** 
  138.       LEFTBARREL=1 : RIGHTBARREL=1 : Rem *** reloaded both barrels ****** 
  139.    End If 
  140.    '
  141. '********** if skeets stopped moving turn them off **********
  142.    If Chanmv(3)=0 Then Bob Off 3 : Amal Off 3
  143.    If Chanmv(4)=0 Then Bob Off 4 : Amal Off 4
  144.    '
  145. Until SHOTS=20 : Rem *** repeat until 20 shots fired *******
  146. '
  147. '
  148. '**** Ok! There should be enough information in the  REMS  above to give *** 
  149. '**** you some idea of how the section works. Now try to follow the
  150. '**** next section, target shooting and try to see how it works. 
  151. '**** Don't try to rush. AMOS take a while to learn, even the simply 
  152. '**** routines take time to get right. The best of luck. 
  153. '
  154. '
  155. LEVEL2: Rem ************** target shooting **************
  156. LEVEL=2 : SHOTS=0
  157. Get Sprite Palette 
  158. Bob 9,230,20,17
  159. Bob 3,100,165,15 : Limit Bob 3,0,0 To 320,163
  160. LEFTBARREL=1 : RIGHTBARREL=1
  161. Screen 1
  162. Cls 
  163. Locate 29,0 : Print "SHOTS ";SHOTS; : Locate 47,0 : Print "SCORE ";SCORE
  164. Screen 0
  165. Wait 200
  166. WHERETARGET=Rnd(185)+80
  167. Bob 3,WHERETARGET,165,15 : Limit Bob 3,0,0 To 320,163 : Amal 3,TARGET$
  168. Amal On 3 : Wait Vbl 
  169. Do 
  170.    '
  171.    MIDDLEX=X Bob(3)+135 : MIDDLEY=198
  172.    MOUSEX=X Mouse : MOUSE=Y Mouse
  173.    XAIM=240+((X Mouse-MIDDLEX)*6)
  174.    YAIM=((Y Mouse-MIDDLEY)*7)+Y Mouse
  175.    KEY=Mouse Key
  176.    '
  177.    If(KEY=1) and(LEFTBARREL=1)
  178.       Bob 10,XAIM+26,YAIM-143,16
  179.       Sam Play 1,2
  180.       Y Mouse=Y Mouse-10
  181.       LEFTBARREL=0
  182.       Inc SHOTS
  183.       CHECKSCORE=Point(X Bob(10),Y Bob(10))
  184.       If CHECKSCORE=2 : Add SCORE,100 : Wait 10 : Sam Play 3,1 : End If 
  185.       If CHECKSCORE=11 : Add SCORE,50 : End If 
  186.       If CHECKSCORE=31 : Add SCORE,20 : End If 
  187.    End If 
  188.    '
  189.    If(KEY=2) and(RIGHTBARREL=1)
  190.       Bob 11,XAIM+26,YAIM-143,16
  191.       Sam Play 2,2
  192.       Y Mouse=Y Mouse-10
  193.       RIGHTBARREL=0
  194.       Inc SHOTS
  195. If X Bob(10)=X Bob(11) : Bob 11,X Bob(10)+5,, : End If 
  196.      CHECKSCORE=Point(X Bob(11),Y Bob(11))
  197.       If CHECKSCORE=2 : Add SCORE,100 : Wait 10 : Sam Play 3,1 : End If 
  198.       If CHECKSCORE=11 : Add SCORE,50 : End If 
  199.       If CHECKSCORE=31 : Add SCORE,20 : End If 
  200.    End If 
  201.    '
  202.    '
  203.    If SHOTS=20 Then End : Rem *** Its over, its over, its ooooovvver ***   
  204.    If(LEFTBARREL=0) and(RIGHTBARREL=0)
  205.       Wait 20
  206.       Y Mouse=Y Mouse+20
  207.     '  Paste Bob 230,20,17 
  208.       Gosub RELOAD
  209.    '   Bob Off 9 : Bob Off 10 : Bob Off 11
  210.       LEFTBARREL=1 : RIGHTBARREL=1
  211.       WHERETARGET=Rnd(185)+80
  212.       Bob 3,WHERETARGET,165,15 : Limit Bob 3,0,0 To 320,163 : Amal 3,TARGET$
  213.       Amal On 3 : Wait Vbl 
  214.    End If 
  215. Loop : Rem **************** end of target shooting ***********
  216. '
  217. SKEETFIRE:
  218. '
  219. CLOCK=Rnd(100)+1 : Wait CLOCK
  220. '
  221. WHICHHUT=Rnd(2)+1
  222. '
  223. If(WHICHHUT=1) and(Chanmv(3)<>-1)
  224.    Bob 3,30,225,7 : Amal 3,SKEET1$ : Amal On 3
  225.    Limit Bob 3,0,0 To 320,220
  226.    Inc SKEETS
  227. End If 
  228. '
  229. If(WHICHHUT=2) and(Chanmv(4)<>-1)
  230.    Bob 4,280,225,7 : Amal 4,SKEET2$ : Amal On 4
  231.    Limit Bob 4,0,0 To 320,220
  232.    Inc SKEETS
  233. End If 
  234. '
  235. If(WHICHHUT=3) and(LEFTBARREL=1) and(RIGHTBARREL=1)
  236.    If(Chanmv(3)<>-1) and(Chanmv(4)<>-1)
  237.       Bob 3,30,225,7 : Amal 3,SKEET1$
  238.       Limit Bob 3,0,0 To 320,220
  239.       Bob 4,280,225,7 : Amal 4,SKEET2$
  240.       Limit Bob 4,0,0 To 320,220
  241.       Add SKEETS,2 : Amal On 3 : Amal On 4
  242. End If : End If 
  243. '
  244. Screen 1
  245. Print "   SKEETS ";SKEETS; : Print "      SHOTS ";SHOTS; : Print "       HITS ";HITS; : Print "       MISSES ";MISSES; : Print "       SCORE ";SCORE
  246. Screen 0
  247. '
  248. Y Mouse=273
  249. Return 
  250. '
  251. '****** This section reloads the gun. That could be why I called it reload ***   
  252. RELOAD:
  253. Wait 50
  254. Bob Off 9 : Bob Off 10 : Bob Off 11
  255. Amal Freeze 1
  256. Repeat : Until(Chanmv(3)=0) and(Chanmv(4)=0)
  257. Bob Off 3 : Bob Off 4 : Hide 
  258. If LEVEL=1
  259.    Screen 1
  260.    Print "   SKEETS ";SKEETS; : Print "      SHOTS ";SHOTS; : Print "       HITS ";HITS; : Print "       MISSES ";MISSES; : Print "       SCORE ";SCORE
  261.    Screen 0
  262. End If 
  263. If(LEVEL=2) or(LEVEL=3)
  264.    Screen 1
  265.    Locate 29,0 : Print "SHOTS ";SHOTS; : Locate 47,0 : Print "SCORE ";SCORE
  266.    Screen 0
  267. End If 
  268. For T=Y Bob(1) To 260
  269.    Bob 1,,T,
  270.    Wait Vbl 
  271. Next T
  272. For T=260 To 190 Step -1
  273.    Bob 1,130,T,3
  274.    Bob 2,127,Y Bob(1)+4,4
  275.    Wait Vbl 
  276. Next T
  277. For T=4 To 6
  278.    Bob 2,,194,T
  279.    Wait 2
  280. Next T
  281. Bob 2,,260,4
  282. Wait 50
  283. For T=6 To 4 Step -1
  284.    Bob 2,,194,T
  285.    Wait Vbl 
  286. Next T
  287. Bob 2,,194,4
  288. For T=190 To 260
  289.    Bob 1,,T,
  290.    Bob 2,,T+4,
  291.    Wait Vbl 
  292. Next T
  293. Wait 50
  294. For T=260 To 230 Step -1
  295.    Bob 1,131,T,1
  296.    Bob Off 2
  297.    Wait Vbl 
  298. Next T
  299. X Mouse=289 : Y Mouse=273
  300. Wait Vbl 
  301. DESTROYED=0
  302. Show On 
  303. Amal On 1
  304. If LEVEL=2 Then Get Sprite Palette : Bob 9,230,20,17
  305. Wait 50
  306. Return 
  307. '
  308. '************** That's the end of the road folks *******************************