1. with Objects;                           use Objects; 
  2. with Maps;                              use Maps; 
  3.  
  4. private with Tiles.Libraries; 
  5.  
  6. package Physics.Clip_Maps is 
  7.  
  8.     type Clip_Map is new Object with private; 
  9.     type A_Clip_Map is access all Clip_Map'Class; 
  10.  
  11.     -- Creates a new empty clip map. 'width' and 'height' and the size of the 
  12.     -- map in tiles, and 'tileWidth' is the size of a tile in pixels. An 
  13.     -- exception is raised on error. 
  14.     function Create_Clip_Map( width, 
  15.                               height, 
  16.                               tileWidth : Positive; 
  17.                               mapLayers : not null A_Layer_Array; 
  18.                               libName   : String ) return A_Clip_Map; 
  19.     pragma Precondition( libName'Length > 0 ); 
  20.     pragma Postcondition( Create_Clip_Map'Result /= null ); 
  21.  
  22.     -- Returns the type of clipping found at a map location in pixels. 
  23.     function Get( this : not null access Clip_Map'Class; 
  24.                   x, y : Float ) return Clip_Type; 
  25.  
  26.     -- Returns the type of clipping found at a map location in tiles. The upper 
  27.     -- left tile in the map is at 0, 0. 
  28.     function Get( this : not null access Clip_Map'Class; 
  29.                   x, y : Integer ) return Clip_Type; 
  30.  
  31.     -- Returns the map's height in pixels. 
  32.     function Get_Height( this : not null access Clip_Map'Class ) return Positive; 
  33.  
  34.     -- Returns the map's width in pixels. 
  35.     function Get_Width( this : not null access Clip_Map'Class ) return Positive; 
  36.  
  37.     -- Sets the id of a tile at a location in the map. The clip map is updated 
  38.     -- appropriately with the new proper type of clipping at that location. 
  39.     procedure Set_Tile( this  : not null access Clip_Map'Class; 
  40.                         id    : Natural; 
  41.                         x, y  : Natural; 
  42.                         layer : Natural ); 
  43.  
  44.     -- Returns the size of a tile in pixels that the clip map is using. 
  45.     function Tile_Width( this : not null access Clip_Map'Class ) return Positive; 
  46.  
  47.     -- Deletes the clip map. 
  48.     procedure Delete( this : in out A_Clip_Map ); 
  49.     pragma Postcondition( this = null ); 
  50.  
  51. private 
  52.  
  53.     use Tiles.Libraries; 
  54.  
  55.     type Clip_Layer is array (Natural range <>) of Clip_Type; 
  56.     type A_Clip_Layer is access all Clip_Layer; 
  57.  
  58.     type Clip_Map is new Object with 
  59.         record 
  60.             mapWidth,                               -- width in pixels 
  61.             mapHeight,                              -- height in pixels 
  62.             mapWidthTiles,                          -- width in tiles 
  63.             mapHeightTiles,                         -- height in tiles 
  64.             tileWidth      : Positive := 1;         -- size of a tile in pixels 
  65.             mapLayers      : A_Layer_Array := null; -- the actual map in tiles 
  66.             clipLayer      : A_Clip_Layer := null; 
  67.             lib            : A_Tile_Library := null; 
  68.         end record; 
  69.  
  70.     procedure Calculate_Clipping( this : not null access Clip_Map'Class; 
  71.                                   x, y : Integer ); 
  72.  
  73.     -- Raises an exception if library 'libName' can't be loaded. 
  74.     procedure Construct( this      : access Clip_Map; 
  75.                          width, 
  76.                          height, 
  77.                          tileWidth : Positive; 
  78.                          mapLayers : not null A_Layer_Array; 
  79.                          libName   : String ); 
  80.  
  81.     procedure Delete( this : in out Clip_Map ); 
  82.  
  83. end Physics.Clip_Maps;