with Entities; use Entities;
with Physics.Clip_Maps; use Physics.Clip_Maps;
limited with Physics.Managers;
private with Ada.Containers.Ordered_Maps;
package Physics.Bodies is
type Corpus is tagged limited private;
type A_Corpus is access all Corpus'Class;
function Create_Corpus( id : Entity_Id;
width,
height : Natural;
physical : Boolean;
clipped : Boolean;
manager : access Physics.Managers.Physics_Manager'Class
) return A_Corpus;
function Detect_Collision( this : not null access Corpus'Class;
that : not null A_Corpus ) return Boolean;
function Get_Id( this : not null access Corpus'Class ) return Entity_Id;
function Is_Touching( this : not null access Corpus'Class;
that : not null A_Corpus ) return Boolean;
procedure Mark_Contact( this : not null access Corpus'Class;
that : not null A_Corpus;
inContact : Boolean );
procedure Move_To( this : not null access Corpus'Class;
map : not null A_Clip_Map;
x, y : Float );
procedure Set_AX( this : not null access Corpus'Class; ax : Float );
procedure Set_AY( this : not null access Corpus'Class; ay : Float );
procedure Set_Clipped( this : not null access Corpus'Class;
clipped : Boolean );
procedure Set_Location( this : not null access Corpus'Class;
map : not null A_Clip_Map;
x, y : Float );
procedure Set_Physical( this : not null access Corpus'Class;
physical : Boolean );
procedure Set_Size( this : not null access Corpus'Class;
map : not null A_Clip_Map;
width,
height : Natural );
procedure Set_Target_VX( this : not null access Corpus'Class; vx : Float );
procedure Set_Target_VY( this : not null access Corpus'Class; vy : Float );
procedure Set_Velocity( this : not null access Corpus'Class; vx, vy : Float );
procedure Tick( this : not null access Corpus'Class;
map : not null A_Clip_Map;
dt : Float;
collide : out Boolean );
function To_String( this : access Corpus'Class ) return String;
procedure Delete( this : in out A_Corpus );
pragma Postcondition( this = null );
private
package Corps_Maps is new Ada.Containers.Ordered_Maps( Entity_Id, A_Corpus, "<", "=" );
type Corpus is tagged limited
record
manager : access Physics.Managers.Physics_Manager'Class := null;
eid : Entity_Id := INVALID_ID;
width,
height : Natural := 0;
width_2,
height_2 : Natural := 0;
physical : Boolean := True;
clipped : Boolean := True;
collide : Boolean := True;
x, y,
oldX, oldY : Float := 0.0;
vx, vy,
tvx, tvy,
ax, ay : Float := 0.0;
standing : Boolean := False;
touching : Corps_Maps.Map;
end record;
procedure Apply_Forces( this : not null access Corpus'Class; dt : Float );
procedure Clip( this : not null access Corpus'Class; map : not null A_Clip_Map );
end Physics.Bodies;