1. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  2.  
  3. package Entities.Items is 
  4.  
  5.     -- An Item is an animated Entity, unaffected by gravity, that gives the 
  6.     -- player a bonus when he touches it. It automatically destroys itself on 
  7.     -- collision so the bonus is only given once. 
  8.     type Item is abstract new Entity with private; 
  9.     type A_Item is access all Item'Class; 
  10.  
  11.     -- Returns a reference to a bitmap icon that represents the item. This can 
  12.     -- used for displaying a visual representation of the item, in a palette, 
  13.     -- for instance. The reference returned is owned by the item. Do not modify 
  14.     -- it. 
  15.     function Get_Icon( this : access Item ) return A_Bitmap; 
  16.  
  17.     -- Gives the item's bonus to the player. Each item class gives a different 
  18.     -- bonus. This is called when the Player entity collides with the Item. 
  19.     procedure Give_Item( this : access Item ) is abstract; 
  20.  
  21. private 
  22.  
  23.     type Item is abstract new Entity with 
  24.         record 
  25.             frameDelay : Time_Span := Time_Span_Zero; 
  26.             firstFrame : Natural := 0; 
  27.             maxFrames  : Positive := 1; 
  28.         end record; 
  29.  
  30.     -- Constructs the Item. Constructors of subclasses should call this first. 
  31.     -- Raises an exception on error. 
  32.     procedure Construct( this       : access Item; 
  33.                          width, 
  34.                          height     : Natural; 
  35.                          libName    : String; 
  36.                          firstFrame : String; 
  37.                          maxFrames  : Positive; 
  38.                          frameDelay : Time_Span ); 
  39.  
  40.     -- Implements the entity On_Collide behavior to call Give_Item if the 
  41.     -- colliding entity is a player. An overriding implemetation should call 
  42.     -- this first. 
  43.     procedure On_Collide( this : access Item; e : not null A_Entity ); 
  44.  
  45.     -- Executes one time frame of logic for the Item to keep the frame up to 
  46.     -- date. An overriding implementation must call this first. 
  47.     procedure Tick( this : access Item; time : Tick_Time ); 
  48.  
  49.     procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Item ); 
  50.     for Item'Read use Object_Read; 
  51.  
  52.     procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Item ); 
  53.     for Item'Write use Object_Write; 
  54.  
  55.     -- Deletes the Item. 
  56.     procedure Delete( this : in out A_Item ); 
  57.     pragma Postcondition( this = null ); 
  58.  
  59. end Entities.Items;