home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Amos / amproe2x.dms / in.adf / Compiler_Examples / AMOS_versions / BouncBobs.AMOS / BouncBobs.amosSourceCode
Encoding:
AMOS Source Code  |  1993-06-16  |  3.0 KB  |  161 lines

  1. ' ---------------------------------  
  2. '
  3. ' AMOSPro Compiler Example 
  4. '
  5. ' Bouncin' Bobs
  6. '
  7. ' By Jean-Baptiste BOLCATO 
  8. '
  9. ' (c) 1993 Europress Software Ltd. 
  10. '
  11. ' ---------------------------------  
  12. '
  13. ' ---------------------------------------------------  
  14. '  remark:  Shows how many Bobs can be displayed and moved 
  15. '           at speed. Note the turning off of Multi-tasking below.   
  16. '           This will speed up your Bobs and avoid them 'sticking'.  
  17. '           when there's another task taking too much time.
  18. '
  19. '           Average Acceleration:  320 % 
  20. '
  21. '           Test configuration: A1200, 6Mb 
  22. '
  23. '           Original AMOS Compiler:  250 % 
  24. ' ---------------------------------------------------        
  25.  
  26.  
  27. ' ---- Variables Init ---- 
  28.  
  29. Dim X(128),Y(128),VX(128),VY(128),N(10)
  30.  
  31. For I=1 To 128
  32.    X(I)=0
  33.    Y(I)=8+Rnd(200)
  34.    VX(I)=Rnd(4)+1
  35.    VY(I)=Rnd(4)+1
  36. Next I
  37.  
  38. YMAX=256+56*(Ntsc=True)
  39. VYMAX=10+3*(Ntsc=True)
  40. N2=0 : N=1 : T=1
  41.  
  42. ' ---- Screen Init ----
  43.  
  44. Screen Open 0,320,YMAX,4,Lowres
  45. Screen Hide 0
  46. Flash Off : Curs Off : Hide 
  47. Palette 0,$FFF,$BBB,$888
  48. Paper 0 : Pen 1
  49.  
  50. ' ---- Init bobs ----  
  51.  
  52. Load Iff "AMOSPro_Extras:Compiler_Examples/Graphics/Sprites_pic.iff",0
  53. Get Bob 1,0,0 To 16,16
  54.  
  55. Cls 0 : Wait Vbl 
  56. Paper 0 : Pen 1
  57. Double Buffer 
  58.  
  59. ' Set bob backsave to color 0  
  60. For I=1 To 63
  61.    Set Bob I,1,,
  62. Next I
  63.  
  64. ' ---- Init Rainbow ---- 
  65.  
  66. Set Rainbow 0,0,64,"","",""
  67. YR=0
  68. For I=0 To 15
  69.    For J=1 To I/2
  70.       Inc YR
  71.       Rain(0,YR)=(15-I)*$110
  72.    Next J
  73. Next I
  74. Rainbow 0,0,YMAX,40
  75. Screen Show 0
  76.  
  77. ' ---- Main Loop ----
  78.  
  79. ' Error managment  
  80. On Error Proc _ERROR
  81. Resume Label _EXIT
  82. OVERFLOW_BOB=False
  83. YMAX=Y Screen(YMAX)
  84.  
  85. ' Switch OFF multitask 
  86. Amos Lock : Break Off 
  87. Dreg(0)=Execall(-132)
  88.  
  89. Repeat 
  90.  
  91.    CPT=0
  92.  
  93.    Repeat 
  94.       
  95.       ' Add a new bob every 16 loops.
  96.       Inc N2
  97.       If N2=16
  98.          N2=0
  99.          Inc N
  100.       End If 
  101.       Timer=0
  102.       For I=1 To N
  103.          
  104.          ' Setup gravity & x speed
  105.          Inc VY(I)
  106.          Add X(I),VX(I)
  107.          Add Y(I),VY(I)
  108.          
  109.          ' ybounce! 
  110.          If Y(I)>=YMAX : Y(I)=YMAX : VY(I)=-10-Rnd(VYMAX) : End If 
  111.          
  112.          ' xbounce! 
  113.          If X(I)>304 or X(I)<0 : VX(I)=-VX(I) : End If 
  114.          
  115.          ' Display (if it's possible, else jump to _EXIT!)
  116.          Bob I,X(I),Y(I),1
  117.          
  118.       Next I
  119.  
  120.       Wait Vbl : If Timer>T : Inc CPT : End If 
  121.  
  122.    Until CPT>4
  123.    
  124.    ' Report Message 
  125.    Bell : Home 
  126.    N(T)=N
  127.    Print "< Needs";N(T);" bobs to pass under";T;" VBL >"
  128.    Inc T
  129.  
  130. Until T=7
  131.  
  132. _EXIT:
  133.  
  134. ' --- Final Report --- 
  135.  
  136. ' Switch ON  multitask 
  137. Dreg(0)=Execall(-138)
  138. Amos Unlock : Break On 
  139.  
  140. Autoback 1 : Home 
  141. Print "     --- Final status report ---     "
  142. Print 
  143. T2=T-1-(OVERFLOW_BOB=True)
  144. For T2=1 To T-1
  145.    Print "< Needs";N(T2);" bobs to pass under";T2;" VBL >"
  146. Next T2
  147. If OVERFLOW_BOB : Print : Print "--- Error: Bobs-overflow Error ! ---" : End If 
  148. Print "     Press mouse key to end"
  149. Repeat 
  150.    Multi Wait 
  151. Until Mouse Key or(Inkey$<>"")
  152.  
  153. End 
  154.  
  155. ' ---- Error ----
  156.  
  157. Procedure _ERROR
  158.    Shared OVERFLOW_BOB
  159.    OVERFLOW_BOB=True
  160.    Resume Label 
  161. End Proc