1. private with Tiles; 
  2.  
  3. package Entities.Sprites is 
  4.  
  5.     -- A Sprite in an Entity that doesn't have any internal behavior. It can 
  6.     -- represent something simply to be displayed, like an explosion, or a 
  7.     -- phaser blast, or a little animation displayed when an item is collected. 
  8.     type Sprite is abstract new Entity with private; 
  9.  
  10. private 
  11.  
  12.     use Tiles; 
  13.  
  14.     type Sprite is abstract new Entity with 
  15.         record 
  16.             -- ** constant for the life of the object; fields not streamed ** 
  17.             lifeSpan   : Time_Span := Time_Span_Zero; 
  18.             frameDelay : Time_Span := Time_Span_Zero; 
  19.             frames     : A_Tile_Id_Array := null; 
  20.         end record; 
  21.  
  22.     -- Constructs the Sprite. Subclasses should call this from their constructor. 
  23.     -- 'frames' is an animation for the sprite, as a list of tile IDs from tile 
  24.     -- library 'libName'. The animation will loop after the last frame. The 
  25.     -- sprite will not display an animation if it has only one frame. 'lifeSpan' 
  26.     -- is the length of time the entity should exist before it automatically 
  27.     -- deletes itself (0 = unlimited). 'frameDelay' is the amount of time 
  28.     -- between frames. 
  29.     procedure Construct( this       : access Sprite; 
  30.                          width, 
  31.                          height     : Natural; 
  32.                          libName    : String; 
  33.                          frames     : not null A_Tile_Id_Array; 
  34.                          lifeSpan   : Time_Span; 
  35.                          frameDelay : Time_Span ); 
  36.     pragma Precondition( libName'Length > 0 ); 
  37.  
  38.     procedure Delete( this : in out Sprite ); 
  39.  
  40.     procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Sprite ); 
  41.     for Sprite'Read use Object_Read; 
  42.  
  43.     procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Sprite ); 
  44.     for Sprite'Write use Object_Write; 
  45.  
  46.     -- Inherited from Entity. Executes one time frame of the Sprite's logic. 
  47.     -- This keeps the animation frame up to date and destroy the entity when 
  48.     -- it's beyond it's lifespan. An overriding implementation should call this 
  49.     -- first. 
  50.     procedure Tick( this : access Sprite; time : Tick_Time ); 
  51.  
  52.     -- Displays the next frame in the sprite's animation, as necssary.. If 
  53.     -- 'notify' is True and the frame changes, a Frame_Changed event will be 
  54.     -- sent to the game view. 
  55.     procedure Update_Frame( this   : access Sprite; 
  56.                             notify : Boolean := True ); 
  57.  
  58. end Entities.Sprites;