home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Amos / AmosCRAFT2Turbo.DMS / in.adf / demos / RiverRaid.AMOS / RiverRaid.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1994-02-12  |  5.4 KB  |  160 lines

  1. 'A little River Raid clone in progress...' 
  2.  
  3. 'this program has banks included in it,  
  4. 'If you type Erase 6 in direct mode, it will attempt to reload the banks 
  5. 'with the next few lines of code.  This is a convienience for the programmer 
  6. 'The banks are not included on the disk anywhere because there was no
  7. 'room left over!  You can create the banks by doing the following: 
  8. 'In Direct mode: Save "RiverRaid-icons.abk",2
  9. 'Save "RiverRaid.scene",6
  10. 'You can then load the scene and icons into Scene Editor, save IFF if you like.
  11. 'You'll be able to edit the scene then!
  12.  
  13. 'the sprite in bank one is just a quicky!
  14. 'please ignore the terrible graphics.  This is a scroll demo, not a real game! 
  15.  
  16. 'This program uses a hardware scroll (Screen Offset) on a double height screen.
  17. 'This technique allows a smooth scroll (because no use of slow Scroll commands)
  18. 'of a huge scene. The technique is explained in detail in
  19. 'Ultimate AMOS, by Jason Holburn, sold through Amiga Format. 
  20. 'look for more detail and info in PLAYFIELD! and on TURBO demo disks 
  21. 'This program runs smoother under NTSC system.  You will need to fine tune 
  22. 'to make it run smoothly under PAL..  Try adjusting Vbl Wait 
  23.  
  24. 'You can hack this code any which way you desire.  The way it is set up now  
  25. 'is relatively easy to understand.  You have the basis of a vertical scroll game.  
  26.  
  27. If Length(6)=0
  28.    Load "RiverRaid-icons.abk"
  29.     Extension_12_09B2 "RiverRaid.scene",6
  30. End If 
  31.  Extension_12_06C6 6
  32.  
  33. 'this is the status screen at the bottom 
  34.  
  35. Screen Open 1,320+16,10,8,Lowres
  36. Cls 2 : Flash Off : Curs Off : Print "Score:                Fuel:"; : Home 
  37. Screen Display 1,112,40+192-1,,
  38.  
  39. 'this is the game screen itself
  40.  
  41. HGT=192*2+32 : Rem height of entire screen to open. Visible area (192) * 2 + 2 hidden areas of 16 pixels each (32)
  42. Screen Open 0,320+16,HGT,16,Lowres
  43. Curs Off : Cls 0 : Flash Off : Get Icon Palette 
  44. Screen Display 0,112,40,320+16,190
  45. Colour 18,$FFF
  46. 'Double Buffer : Autoback 0 : Update Off 
  47. Hide On 
  48.  
  49. 'show bottom half of screen
  50. YOFFSET=HGT-192-16 : Rem +2 to prep it for the scroll to occur immediately
  51. Screen Offset 0,0,YOFFSET
  52.  
  53. YSCENE= Extension_12_091A -13
  54.  Extension_12_0736 0,YSCENE,21,14,0,YOFFSET-16
  55. Inc YSCENE
  56. 'we need to draw yscene at yoffset-16 and at yoffset+192 
  57.  
  58. 'ship is a sprite and we use hardware coordinates for him. 
  59. 'when we convert to screen coords, it automatically takes into 
  60. 'account the screen offset...
  61. XSHIP=200 : YSHIP=200 : XOF=0 : YOF=0
  62. Global XSHIP,YSHIP,XOF,YOF
  63.  
  64. 'the next line is for smoothness of operation.  During testing and development,
  65. 'you may wish to comment out this line so you can stop your program. 
  66. 'Also, in AMOS if Multi No is on and your program stops because of an
  67. 'error, you will have to reboot. 
  68.  Extension_12_0016 : Amos Lock : Break Off 
  69. Repeat 
  70.    'this part scrolls the screen
  71.    
  72.    If(YOFFSET mod 16)=0
  73.       'We are at a 16 pixel boundary, its time to draw new icons 
  74.       Dec YSCENE
  75.       If YSCENE=-1
  76.          'what to do when we reach the top of the scene 
  77.          'here we just reset to the bottom!  You could load a new level,
  78.          'go to a big boss scene, whatever! 
  79.          YSCENE= Extension_12_091A -1
  80.       End If 
  81.        Extension_12_0736 0,YSCENE,21,1,0,YOFFSET-16
  82.        Extension_12_0736 0,YSCENE,21,1,0,YOFFSET+192
  83.    End If 
  84.    Add YOFFSET,-1
  85.    If YOFFSET=0
  86.       'here we have hardware scrolled to the top of the screen,
  87.       'now flip to the bottom, ha!  its exactly the same as the top
  88.       'was, so you see no difference!
  89.       YOFFSET=HGT-192-16
  90.       Colour 5,Rnd($FFF) : Rem this just changes a colour so you can see when it happens! 
  91.    End If 
  92.    
  93.    'this part controls the ship 
  94.    'it sets xof and yof to be the offest to add to the ship 
  95.    'if xof =1, move ship to right, etc. 
  96.    
  97.    _MOVESHIP
  98.    
  99.    'check for collisions between ship and ground
  100.    
  101.    _CHECKGROUND
  102.    HIT=Param
  103.    'heres what we do if the ship hits ground! 
  104.    'right now we just move it to the right a bit. 
  105.    'we could use hit bitpattern to tell which side or nose hit.  See CHECKGROUND for info 
  106.    If HIT : XOF=-1 : End If 
  107.    
  108.    'actually move the ship
  109.    
  110.    Add XSHIP,XOF : Add YSHIP,YOF
  111.    
  112.     Extension_12_00A6 230 : Rem we only need to wait until scanline gets to status screen  
  113.    Sprite 1,XSHIP,YSHIP,1
  114.    Screen Offset 0,0,YOFFSET
  115. Until Extension_12_0392 
  116.  Extension_12_0006 : Amos Unlock : Break On : Show On 
  117. Edit 
  118.  
  119. Procedure _MOVESHIP
  120.    XOF=0 : YOF=0
  121.    If Jup(1)
  122.       YOF=-1
  123.    Else 
  124.       If Jdown(1)
  125.          YOF=1
  126.       End If 
  127.    End If 
  128.    If Jleft(1)
  129.       XOF=-1
  130.    Else 
  131.       If Jright(1)
  132.          XOF=1
  133.       End If 
  134.    End If 
  135. End Proc
  136.  
  137. Procedure _CHECKGROUND
  138.    'we use F Point to check some points on the screen around the sprite 
  139.    
  140.    X=X Screen(XSHIP) : Y=Y Screen(YSHIP)
  141.    
  142.    'uncomment this line to see where hotspot of ship is located 
  143.    '   F Plot X,Y,0 
  144.    
  145.    'start checking at nose, because thats probably the first place to hit something 
  146.    'Here we check only nose & wing tips 
  147.    'any colour below 4 is ok to hit (0-3).  That would be all blues for water.
  148.    HIT=0
  149.    HIT=-%1*( Extension_12_044C(X+5,Y)>3)
  150.    Add HIT,-%10*( Extension_12_044C(X,Y+6)>3)
  151.    Add HIT,-%100*( Extension_12_044C(X+9,Y+6)>3)
  152.  
  153.    'HIT returns a bitpattern. 
  154.    'if 0, no hit occured
  155.    'if %1, nose hit something 
  156.    'if %10, left wing hit something 
  157.    'if %100,right wing hit something
  158.    'example, if %11, nose and left wing hit something 
  159.    'just a bit more flexible and faster than if/thens 
  160. End Proc[HIT]