1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  10.  
  11. package Entities.Enemies is 
  12.  
  13.     type Enemy is abstract new Entity with private; 
  14.     type A_Enemy is access all Enemy'Class; 
  15.  
  16.     -- Returns a reference to a bitmap icon that represents the enemy. The 
  17.     -- returned reference is owned by the enemy. Do not modify it! 
  18.     function Get_Icon( this : not null access Enemy'Class ) return A_Allegro_Bitmap; 
  19.  
  20.     -- Returns True if the enemy is shootable (meaning it blocks shots fired at 
  21.     -- it.) Being shootable does not imply that the enemy will react in any 
  22.     -- specific way if instructed to die. 
  23.     function Is_Shootable( this : not null access Enemy'Class ) return Boolean; 
  24.  
  25.     -- Notify the enemy that something deadly happened to it and it should die. 
  26.     -- If the enemy is not currently capable of dying, nothing should happen. 
  27.     -- The default behavior is to do nothing. Override this procedure to cause 
  28.     -- the enemy to react in some way. 
  29.     procedure Die( this : access Enemy ); 
  30.  
  31.     -- A class pattern that matches all enemy class ids registered in the entity 
  32.     -- factory. 
  33.     CLASS_PATTERN : constant String := "Entities.Enemies.*"; 
  34.  
  35. private 
  36.  
  37.     type Enemy is abstract new Entity with 
  38.         record 
  39.             icon        : Integer := 0;        -- used by KEd 
  40.             deadlyTouch : Boolean := True;     -- is the enemy deadly to the player? 
  41.             shootable   : Boolean := True;     -- can the player's shots hit it? 
  42.         end record; 
  43.  
  44.     -- Raises an exception on error. 
  45.     procedure Construct( this     : access Enemy; 
  46.                          width, 
  47.                          height   : Natural; 
  48.                          libName  : String; 
  49.                          iconName : String ); 
  50.  
  51.     procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Enemy ); 
  52.     for Enemy'Read use Object_Read; 
  53.  
  54.     procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Enemy ); 
  55.     for Enemy'Write use Object_Write; 
  56.  
  57.     -- Players colliding with enemies deadly to the touch will be killed. 
  58.     procedure On_Collide( this : access Enemy; e : not null A_Entity ); 
  59.  
  60.     procedure Delete( this : in out A_Enemy ); 
  61.     pragma Postcondition( this = null ); 
  62.  
  63. end Entities.Enemies;