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