home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / 351-375 / apd375 / progs / starfield.amos / starfield.amosSourceCode
AMOS Source Code  |  1992-05-23  |  5KB  |  147 lines

  1. 'DATE: 02/02/92
  2. 'TIME: 22:48 
  3. 'NAME: STARFIELD.AMOS
  4. 'CODE: UNCLE SIME
  5. 'NOTE: I BECAME VERY DEPRESSED BY THE EXAMPLES OF STARFIELDS THAT  
  6. '      HAVE BEEN ON THIS AND OTHER AMOS PROG DISKS, SO I PUT THIS
  7. '      TOGETHER. IF YOU REALLY WANT THIS ROUTINE TO HUM THEN DUMP  
  8. '      AMAL AND UPDATE THE STARS COORDINATES MANUALLY! 
  9. 'THOUGHT FOR THE DAY: If You Can't Get Out Of It..Get Into It! 
  10. ' Simple little procedure this one. If you want help drop a note to  
  11. ' the address below. INCLUDE POSTAGE OR YOU WILL NOT GET A REPLY!  
  12. ' The Address:                Uncle Simes  
  13. '                             The Warehouse
  14. '                             118 Hiltingbury Rd,
  15. '                             Chandlers Ford,  
  16. '                             Eastleigh, 
  17. '                             Hants. 
  18. '                             SO5 1NT  
  19. '                * DATA SECTION - VARIABLES ETC *
  20. ' 1] Set the correct disk / directory path 
  21. ' 2] Kill the system environment 
  22. ' 3] Declare a 1D array called STARS$ with 28 elements 
  23. Dir$="SIMES_PROGS1:"
  24. Close Workbench 
  25. Close Editor 
  26. Screen Close 0
  27. Randomize Timer
  28. Dim STARS$(27)
  29. '                       * modULE LEVEL CODE* 
  30. ' 1] Initialise the system 
  31. ' 2] Do the do 
  32. ' 4] End of prog 
  33. '
  34. INITIALISE
  35. MAIN
  36. End 
  37. '                      * PROCEDURE LEVEL CODE *
  38. Procedure MAIN
  39.     ' The main procedure. First make the screen visible. Next display a
  40.     ' rainbow by calling GROUND_RBOW procedure. Now animate the stars
  41.     ' by succesive calls to the synchro command (AMOS manual page 202).  
  42.     ' Finally delete the rainbow, erase the sprite bank and close the  
  43.     ' work screen and return to module level code. 
  44.     Screen Show 0
  45.     Autoback 1
  46.     GROUND_RBOW
  47.     Repeat 
  48.         Synchro 
  49.         Wait 1
  50.     Until Mouse Key=1
  51.     Rainbow Del 
  52.     Erase 1
  53.     Screen Close 0
  54.     Dreg(0)=Execall(-138)
  55. End Proc
  56. Procedure INITIALISE
  57.     ' This procedure initialises the system. Does the following......  
  58.    ' 1] Turn off synchro (AMOS manual page 202) this allows us to use 
  59.     '    more than 16 separate amal programs at once 
  60.     ' 2] Load the sprite bank
  61.     ' 3] Set the sprite buffer (AMOS manual page 151)
  62.     ' 4] Open screen and position it and set colours   
  63.     ' 5] call procedure stars to set amal strings  
  64.     Dreg(0)=Execall(-132)
  65.     Synchro Off 
  66.     Load Dir$+"SPRITES/STAR_SPRITE.ABK"
  67.     Set Sprite Buffer 16
  68.     Screen Open 0,320,70,2,Lowres
  69.     Screen Hide 0
  70.     SET_SCREEN
  71.     Double Buffer 
  72.     Screen Display 0,128,170,320,70
  73.     For LOP=1 To 31
  74.         Colour LOP,$FFF
  75.     Next LOP
  76.     STARS
  77. End Proc
  78. Procedure STARS
  79. Shared STARS$()
  80.     '                       CREDIT WHERE CREDIT IS DUE!
  81.     '                       ---------------------------  
  82.     ' The initial code that I used to create the starfield was done by Nick of 
  83.     ' Hanissis V in their 2nd demo. I changed the routine beacuse despite the    
  84.     ' claim that it was "The fastest, smoothest, multi layer, paralax,     
  85.     ' starfield ever done in AMOS!" IT DIDN'T WORK PROPERLY (grin, grin).
  86.     ' If you have the demo grab the procedure STARFIELD and run it   
  87.     ' independantly and you will find that the stars start to vanish afer  
  88.     ' it has been running for a while, ok they do come back but it tends to
  89.     ' spoil the effect a bit....... Hi Nick what happened to Hanissis V? 
  90.     ' This is the procedure that sets up the amal strings for each of the
  91.     ' 28 stars (28 because we are going from 0 to 27). First I use a For 
  92.     ' loop to give each sprite (numbered from 8 to 35) an initial random 
  93.     ' starting position. The second For loop is then used to assign each 
  94.     ' sprite a speed, and an animation channel. Each sprite is then set to 
  95.     ' run the amal string and voila! NB: note the shared statement at the    
  96.     ' start of the procedure, this allows us to access the star array  
  97.     ' declared at the beginning of the program.
  98.     For STARS=0 To 27
  99.         Sprite STARS+8,128+Rnd(420),170+Rnd(70),1
  100.     Next STARS
  101.     For LOP=0 To 27
  102.         Read STAR_SPEED
  103.         Channel LOP+8 To Sprite LOP+8
  104.         STARS$(LOP)="Begin: Jump Loop; Main: Let X=1; Loop: Let X=X+"+Str$(STAR_SPEED)+"Pause;"
  105.         STARS$(LOP)=STARS$(LOP)+"If X<430 Jump Loop;Pause; Jump Main;"
  106.         Amal LOP+8,STARS$(LOP)
  107.         Wait Vbl 
  108.     Next LOP
  109.     Data 4,5,6,8
  110.     Data 4,5,6,8
  111.     Data 4,5,6,8
  112.     Data 4,5,6,8
  113.     Data 4,5,6,8
  114.     Data 4,5,6,8
  115.     Data 4,5,6,8
  116.     Amal On 
  117. End Proc
  118. Procedure SET_SCREEN
  119.     ' Its that fimilar set the screen proc again 
  120.     Flash Off 
  121.     Curs Off 
  122.     Hide On 
  123.     Cls 0
  124. End Proc
  125. Procedure GROUND_RBOW
  126.     ' Yeh old rainbow. Created using Spages rainbow warrior prog.
  127.     Set Rainbow 0,0,76,"","",""
  128.     Rainbow 0,0,241,76
  129.     Colour Back 0
  130.     Restore RDATA
  131.     For C=0 To 75
  132.         Read CVA
  133.         Rain(0,C)=CVA
  134.     Next C
  135.     View 
  136.     RDATA:
  137.     Data $0,$6,$6,$6,$6,$7,$7,$7
  138.     Data $7,$8,$8,$8,$8,$9,$9,$9
  139.     Data $9,$A,$A,$A,$A,$B,$B,$B
  140.     Data $B,$11C,$11C,$11C,$11C,$22D,$22D,$22D
  141.     Data $22D,$33E,$33E,$33E,$44F,$44F,$44F,$44F
  142.     Data $55F,$55F,$55F,$55F,$66F,$66F,$66F,$66F
  143.     Data $77F,$77F,$77F,$77F,$88F,$88F,$88F,$88F
  144.     Data $99F,$99F,$99F,$99F,$AAF,$AAF,$AAF,$AAF
  145.     Data $BBF,$BBF,$BBF,$BBF,$CCF,$CCF,$CCF,$CCF
  146.     Data $DDF,$DDF,$DDF,$DDF,$EEF,$0,$0,$0
  147. End Proc