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.     -- A class pattern that matches all item class ids registered in the entity 
  22.     -- factory. 
  23.     CLASS_PATTERN : constant String := "Entities.Items.*"; 
  24.  
  25. private 
  26.  
  27.     type Item is abstract new Entity with 
  28.         record 
  29.             frameDelay : Time_Span := Time_Span_Zero; 
  30.             firstFrame : Natural := 0; 
  31.             maxFrames  : Positive := 1; 
  32.         end record; 
  33.  
  34.     -- Constructs the Item. Constructors of subclasses should call this first. 
  35.     -- Raises an exception on error. 
  36.     procedure Construct( this       : access Item; 
  37.                          width, 
  38.                          height     : Natural; 
  39.                          libName    : String; 
  40.                          firstFrame : String; 
  41.                          maxFrames  : Positive; 
  42.                          frameDelay : Time_Span ); 
  43.  
  44.     -- Implements the entity On_Collide behavior to call Give_Item if the 
  45.     -- colliding entity is a player. An overriding implemetation should call 
  46.     -- this first. 
  47.     procedure On_Collide( this : access Item; e : not null A_Entity ); 
  48.  
  49.     -- Executes one time frame of logic for the Item to keep the frame up to 
  50.     -- date. An overriding implementation must call this first. 
  51.     procedure Tick( this : access Item; time : Tick_Time ); 
  52.  
  53.     procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Item ); 
  54.     for Item'Read use Object_Read; 
  55.  
  56.     procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Item ); 
  57.     for Item'Write use Object_Write; 
  58.  
  59.     -- Deletes the Item. 
  60.     procedure Delete( this : in out A_Item ); 
  61.     pragma Postcondition( this = null ); 
  62.  
  63. end Entities.Items;