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. package Physics is 
  10.  
  11.     pragma Pure; 
  12.  
  13.     -- This enumeration describes the physical bounding types of tiles, from 
  14.     -- fully empty to full solid and all the different kinds of slopes. 
  15.     type Clip_Type is ( 
  16.         Passive, 
  17.         OneWay, 
  18.         Wall, 
  19.  
  20.         Slope_45_Up_Floor,   Slope_45_Up_Ceiling, 
  21.         Slope_45_Down_Floor, Slope_45_Down_Ceiling, 
  22.  
  23.         Slope_22_Up_Floor_Thin,   Slope_22_Up_Floor_Wide, 
  24.         Slope_22_Up_Ceiling_Wide, Slope_22_Up_Ceiling_Thin, 
  25.  
  26.         Slope_22_Down_Floor_Wide,   Slope_22_Down_Floor_Thin, 
  27.         Slope_22_Down_Ceiling_Thin, Slope_22_Down_Ceiling_Wide 
  28.     ); 
  29.  
  30.     -- Combines two Clip_Type values and returns the most solid/occlusive one. 
  31.     function "or"( l, r : Clip_Type ) return Clip_Type; 
  32.  
  33.     -- Clips a point to a tile as though the point is moving in the downward 
  34.     -- direction. The amount which the point should be adjusted upward is 
  35.     -- returned in 'adjustY'. 'size' is the size of the tile in pixels and 
  36.     -- 'x', 'y' is the point's location within the area of the tile. 'x' and 'y' 
  37.     -- must be in the range of 0..size-1. 
  38.     -- 
  39.     -- clip    : the clipping type of the tile 
  40.     -- size    : the width/height of the tile 
  41.     -- x, y    : the location of the point to clip within the tile 
  42.     -- adjustY : the distance the point should be moved in the y axis (negative) 
  43.     procedure Clip_Downward( clip    : Clip_Type; 
  44.                              size    : Positive; 
  45.                              x, y    : Natural; 
  46.                              adjustY : out Integer ); 
  47.     pragma Precondition( x < size ); 
  48.     pragma Precondition( y < size ); 
  49.     pragma Postcondition( adjustY <= 0 ); 
  50.     pragma Postcondition( adjustY >= -size ); 
  51.  
  52.     -- Clips a point to a tile as though the point is moving in the upward 
  53.     -- direction. The amount which the point should be adjusted downward is 
  54.     -- returned in 'adjustY'. 'size' is the size of the tile in pixels and 
  55.     -- 'x', 'y' is the point's location within the area of the tile. 'x' and 'y' 
  56.     -- must be in the range of 0..size-1. 
  57.     -- 
  58.     -- clip    : the clipping type of the tile 
  59.     -- size    : the width/height of the tile 
  60.     -- x, y    : the location of the point to clip within the tile 
  61.     -- adjustY : the distance the point should be moved in the y axis (positive) 
  62.     procedure Clip_Upward( clip    : Clip_Type; 
  63.                            size    : Positive; 
  64.                            x, y    : Natural; 
  65.                            adjustY : out Integer ); 
  66.     pragma Precondition( x < size ); 
  67.     pragma Precondition( y < size ); 
  68.     pragma Postcondition( adjustY >= 0 ); 
  69.     pragma Postcondition( adjustY <= size ); 
  70.  
  71.     -- Returns the matching Clip_Type value for a string. The string should be 
  72.     -- the exact name of the enumeration value. 'valid' will return False if 
  73.     -- 'str' is not a valid Clip_Type value. 
  74.     procedure To_Clip_Type( str   : String; 
  75.                             clip  : out Clip_Type; 
  76.                             valid : out Boolean ); 
  77.  
  78.     -- The point at which acceleration is considered to be immediate. Any 
  79.     -- accelerations greater than or equal to this constant will cause an entity 
  80.     -- to immediately reach their target velocity with one tick of the physics 
  81.     -- manager. 
  82.     INSTANT_ACCELERATION : constant Float; 
  83.  
  84. private 
  85.  
  86.     INSTANT_ACCELERATION : constant Float := 100_000.0; 
  87.  
  88. end Physics;