-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentities.adb
54 lines (46 loc) · 1.33 KB
/
entities.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package body Entities is
procedure Initialize(This : out Entity; EntType : in EntityTypes;
Pos, Vel, Grav : in Vec2D; Mat : in Material)
is
begin
This.EntityType := EntType;
This.Coords := Pos;
This.Velocity := Vel;
This.Force := Vec2D'(x => 0.0, y => 0.0);
This.InvMass := 0.0; -- needs to be set for each entity with ComputeMass
This.Mass := 0.0; -- needs to be set for each entity with ComputeMass
This.Mat := Mat;
This.Gravity := Grav;
end Initialize;
procedure ChangeMaterial(This : in out Entity'Class; NewMat : Material)
is
begin
This.Mat := NewMat;
This.ComputeMass;
end ChangeMaterial;
function GetDistance(A, B : in Entity'Class) return Float
is
begin
return Mag(B.GetPosition - A.GetPosition);
end GetDistance;
procedure ApplyForce(This : in out Entity; Force : Vec2D)
is
begin
This.Force := This.Force + Force;
end ApplyForce;
procedure SetGravity(This : in out Entity; Grav : Vec2D)
is
begin
This.Gravity := Grav;
end SetGravity;
procedure SetLayer(This : in out Entity; Lay : Byte)
is
begin
This.Layer := Lay;
end SetLayer;
procedure AddLayer(This : in out Entity; Lay : Byte)
is
begin
This.Layer := This.Layer or Lay;
end AddLayer;
end Entities;