home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / AMAL / AMAL_7.AMOS / AMAL_7.amosSourceCode next >
Encoding:
AMOS Source Code  |  1992-09-28  |  8.4 KB  |  234 lines

  1. '*************************** 
  2. '*    AMOS Professional    * 
  3. '*                         * 
  4. '*         AMAL_7          *                     Autotest
  5. '*                         * 
  6. '* (c) Europress Software  * 
  7. '*                         * 
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. 'General 
  13. '------------------------------------------- 
  14. 'The Amal autotest system allows certain tests to be performed each 1/50th 
  15. 'of a second side-stepping some of the problems that can arise with say a
  16. 'set of move instructions which may take several seconds to complete.
  17. 'Only certain instructions can be used with these routines and there is also 
  18. 'a couple of others that are solely for use with AUtotest. 
  19. '
  20. 'The following is a complete list of instructions that can be used with
  21. 'AUtotest:-
  22. '------------------------------------------- 
  23. 'AUtotest
  24. '------------------------------------------- 
  25. 'keyword AU
  26. '
  27. 'This is the command which defines which tests have to be performed and the
  28. 'action to be taken. 
  29. 'The tests are placed within a pair of brackets following the instruction:-
  30. '
  31. '               AUtotest (list of tests) 
  32. '------------------------------------------- 
  33. 'Let 
  34. '------------------------------------------- 
  35. 'Keyword L 
  36. '
  37. 'This is the standard Amal Let instruction for assigning a value to a
  38. 'register:-
  39. '               Let X=R0 
  40. '------------------------------------------- 
  41. 'Jump
  42. '------------------------------------------- 
  43. 'keyword J 
  44. '
  45. 'This again is the standard Amal Jump instruction which jumps program
  46. 'control to a label, this label must be within the Autotest brackets.
  47. '
  48. '              If R0>XM Jump Label 
  49. '------------------------------------------- 
  50. 'eXit
  51. '------------------------------------------- 
  52. 'keyword X 
  53. '
  54. 'The eXit instruction is used to quit the AUtotest and rejoin the Amal 
  55. 'program at the point it was left. 
  56. '
  57. '              If A=10 eXit
  58. '------------------------------------------- 
  59. 'Wait
  60. '------------------------------------------- 
  61. 'keyword W 
  62. '
  63. 'The Wait command turns off the rest of the Amal program and only executes 
  64. 'the AUtotest routine. This instruction should be issued outside the Autotest
  65. 'brackets. 
  66. '
  67. '              Let X=XM;Let Y=YM;Wait
  68. '
  69. '------------------------------------------- 
  70. 'If
  71. '------------------------------------------- 
  72. 'keyword I 
  73. '
  74. 'This is an extended form of the Amal If instruction which allows three
  75. 'alternative outcomes to the test. 
  76. '
  77. '          If....Jump Label     (jump to another part of the AUtotest) 
  78. '          If....Direct label   (jump to main Amal program label)
  79. '          If....eXit           (quit AUtotest and rejoin program) 
  80. '        
  81. '------------------------------------------- 
  82. 'On
  83. '------------------------------------------- 
  84. 'keyword O 
  85. '
  86. 'The On instruction will restart an Amal program after a previous Wait.
  87. '
  88. '          label: On; Pause Jump Start 
  89. '
  90. '------------------------------------------- 
  91. 'Direct
  92. '------------------------------------------- 
  93. 'keyword D 
  94. '
  95. 'The Direct instruction will quit the Autotest at the next Vbl and rejoin
  96. 'the main Amal program at the given label. this label must be outside the
  97. 'Autotest barckets.
  98. '
  99. '          Direct Loop 
  100. '
  101. '------------------------------------------- 
  102. 'A small example of an Amal AUtotest 
  103. '------------------------------------------- 
  104. '
  105. '   A$=AUtotest(If R0>320 Jump Reverse;          Rem *** start of AUtotest(
  106. '   A$=A$+"If R0<0 Jump Forward; else eXit"
  107. '   A$=A$+"Reverse: Let R1=-1; Direct label"     
  108. '   A$=A$+"Forward: Let R1=1; Direct label)"     Rem *** end of AUtotest)
  109. '   A$=A$+"label: Let X=X+R1; Wait"
  110. '
  111. '------------------------------------------- 
  112. 'End 
  113. '------------------------------------------- 
  114. 'Keyword E 
  115. '
  116. 'The final instruction to complete the Amal list of commands is End, this
  117. 'will terminate an entire Amal program and turn off the AUtotest if it is in 
  118. 'operation:- 
  119. '
  120. '            Quit: End 
  121. '
  122. '------------------------------------------- 
  123. 'complete Amal example 
  124. '------------------------------------------- 
  125. INIT
  126. Dim C$(6)
  127. Auto View Off 
  128. Rem *** load some objects to work with and clear the screen
  129. '
  130. Load "AmosPro_Tutorial:Objects/Amal_Bobs.abk"
  131. Screen Open 1,320,200,4,Lowres : Curs Off : Flash Off : Cls 0
  132. Screen Open 0,320,200,16,Lowres : Flash Off 
  133. Get Sprite Palette : Colour Back $77 : Curs Off : Cls 0 : Hide 
  134. Ink 4 : Box 0,0 To 319,199 : Set Paint 1 : Ink 12,1,4 : Bar 45,7 To 300,15
  135. Limit Mouse 130, To 430, : Make Mask 
  136. Global HITS,F$
  137. '
  138. Rem *** Amal program for moving gun
  139. A$="Label:If RB=1 Jump Image;Let A=11;Let X=XM;Pause Jump Label;Image: Let A=12;Let X=XM;Pause Jump Lable"
  140. Rem *** Amal program for bullet
  141. B$="Anim 0,(9,2)(10,2);LetX=XM;LetY=208;LetRA=1;LetRB=1;Move0,-40,4;LetRB=0;Move0,-160,16;Let RA=0"
  142. Rem *** Amal programs for moving birds 
  143. X$=";LR0=Z(50)+80;FR1=1TR0;P;NR1"
  144. C$(1)=X$+"A 0,(1,2)(2,2)(3,2)(4,2);L X=330;LY=Z(120)+20;M -360,0,120"
  145. C$(2)=X$+"A 0,(5,1)(6,1)(7,1)(8,1);L X=-30;LY=Z(120)+20;M 360,0,90"
  146. C$(3)=X$+"A 0,(1,1)(2,1)(3,1)(4,1);L X=330;LY=Z(80)+95;M -360,-75,90"
  147. C$(4)=X$+"A 0,(5,3)(6,3)(7,3)(8,3);L X=-30;LY=Z(80)+95;M 360,-75,180"
  148. C$(5)=X$+"A 0,(1,3)(2,3)(3,3)(4,3);L X=330;LY=Z(110)+65;M -360,-45,180"
  149. C$(6)=X$+"A 0,(5,2)(6,2)(7,2)(8,2);L X=-30;LY=Z(110)+65;M 360,-45,120"
  150. Rem *** Amal program for timer 
  151. D$="L RZ=0;L X=400;M -230,0,2300;L RZ=1"
  152. Rem *** Amal program for guano 
  153. E$="A 0,(13,6)(14,6)(15,6)(14,6);L X=RX;L Y=RY: L: L Y=Y+2;P;If Y>242 JS JL;S:A0,(17,2)(18,2);FR0=1T75;NR0 LY=300"
  154. Rem *** Amal program for bird death
  155. F$="LA=4;M0,240,20"
  156. '
  157. LEVEL=0 : Paper 0 : Pen 12 : Locate 1,1 : Print "TIME"
  158. Auto View On : Double Buffer 
  159. '
  160. Rem *** start of the main game loop  
  161. Do 
  162.    Screen To Front 0 : Screen 0 : Bob Off : Wait Vbl 
  163.    Pen 8 : Inc LEVEL : Locate 1,23 : Print "LEVEL";LEVEL : TARGET=15+LEVEL*5
  164.    Locate 23,23 : Print "Target ";TARGET;" hits"
  165.    Rem *** assign sprites and bobs to the correct amal channels 
  166.    Sprite 8,128,217,11 : Sprite 10,0,218,9 : Sprite 11,400,58,16 : Sprite 14,0,260,14
  167.    For N=1 To 6 : Bob N,0,300,1 : Channel N To Bob N : Next 
  168.    Amal 8,A$ : Amal On 8 : Amal 11,D$ : Amal On 11 : Wait 2
  169.    Rem *** start of level loop
  170.    Amreg(0)=0 : HITS=0
  171.    Repeat 
  172.       Rem *** restart birds if they are not moving 
  173.       Add N,1,1 To 6
  174.       If Not Chanmv(N)
  175.          Amal N,C$(N) : Amal On N
  176.          Rem *** drop guano if there is none
  177.       Else 
  178.          If Y Sprite(14)>250 and X Bob(N)>0 and X Bob(N)<300
  179.             Amreg(24)=Y Hard(Y Bob(N)) : Amreg(23)=X Hard(X Bob(N))
  180.             Amal 14,E$ : Amal On 14
  181.          End If 
  182.       End If 
  183.       Rem *** fire bullet
  184.       If Amreg(0)=0 and Mouse Key=1
  185.          Amal 10,B$ : Amal On 10 : Shoot 
  186.       End If 
  187.       Rem *** collision routines 
  188.       If Sprite Col(8,14 To 15) Then Flash 27,"(000,2)(FF0,2)(F00,2)" : Amal Freeze 8 : Wait 50 : Flash Off : Colour 27,0 : Amal On 8
  189.       If Spritebob Col(10,1 To 6) Then Proc HIT
  190.       Rem *** end of level loop
  191.    Until Amreg(25)=1
  192.    '
  193.    Rem *** mark up results
  194.    For N=30 To 60 : Bell N : Wait Vbl : Next 
  195.    Amal Off : Sprite Off : Screen To Front 1 : Screen 1 : Cls 0 : Paper 0 : Pen 1
  196.    Locate 0,7 : Centre "***LEVEL"+Str$(LEVEL)+" RESULT***"
  197.    Locate 0,9 : Centre "Target number of hits"+Str$(TARGET)
  198.    Locate 0,11 : Centre "Actual number of hits"+Str$(HITS)
  199.    BONUS=(HITS-TARGET)*(100+LEVEL) : If BONUS<0 Then BONUS=0
  200.    Locate 0,13 : Centre "Bonus points for this round="+Str$(BONUS)
  201.    Repeat : Until Mouse Key=0
  202.    Fade 4,$20,$BB0,
  203.    If HITS=>TARGET
  204.       SCORE=SCORE+BONUS
  205.       Locate 0,15 : Centre "Total score so far"+Str$(SCORE)
  206.       Locate 0,20 : Centre "Press right mouse button to continue"
  207.       Repeat : Until Mouse Key=2
  208.       Fade 2 : Wait 30
  209.    Else 
  210.       Locate 0,15 : Centre "G A M E   O V E R"
  211.       Locate 0,17 : Centre "Final score "+Str$(SCORE)
  212.       Locate 0,22 : Centre "Press right mouse to quit"
  213.       Repeat : Until Mouse Key=2
  214.       Edit 
  215.    End If 
  216. Loop 
  217. '
  218. Procedure HIT
  219.    For N=1 To 6
  220.       If Col(N) Then Sprite 10,500,, : Amal N,F$ : Amal On N : Sam Play 15,1,Rnd(7000)+2000
  221.    Next 
  222.    Inc HITS
  223. End Proc
  224. Procedure INIT
  225.    Curs Off : Cls 6 : Paper 6 : Pen 2
  226.    Locate 0,3 : Centre "CANARY OPEN SEASON"
  227.    Pen 5 : Locate 0,7 : Centre "It's time for some target practice with"
  228.    Locate 0,9 : Centre "the canaries, but these little birdies"
  229.    Locate 0,11 : Centre "have been feeding at the local nuclear"
  230.    Locate 0,13 : Centre "power plant-- so look out for the"
  231.    Locate 0,15 : Centre "radioactive guano!"
  232.    Pen 4 : Locate 0,20 : Centre "Press any mouse key to play."
  233.    Repeat : Until Mouse Key
  234. End Proc