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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 | with
gel.Forge,
gel.Sprite,
Physics,
float_Math,
ada.Calendar,
ada.Text_IO,
ada.Exceptions;
package body gel_demo_Server
is
use ada.Calendar,
ada.Text_IO;
package Math renames float_Math;
task body Item
is
the_World : gel.World.server.view;
begin
accept start
do
the_World := gel.World.server.forge.new_World ("Server", 1, physics.Bullet, null);
the_server_World := the_World.all'Access;
end start;
the_World.start;
declare
-- use type math.Real;
the_Box : constant gel.Sprite.view := gel.Forge. new_box_Sprite (the_World.all'Access,
Site => math.Origin_3D,
Size => (20.0, 1.0, 20.0),
Mass => 0.0);
the_Ball : constant gel.Sprite.view := gel.Forge.new_ball_Sprite (the_World.all'Access,
Mass => 1.0);
next_render_Time : ada.calendar.Time;
Counter : Natural := 0;
Done : Boolean := False;
begin
--- Setup.
--
the_World.Gravity_is ((0.0, -10.0, 0.0));
the_World.add (the_Ball, and_Children => False);
the_Ball .Site_is ((0.0, 10.0, 0.0));
the_Ball.Solid.activate;
the_World.add (the_Box, and_Children => False);
the_Box.Site_is ((0.0, -1.0, 0.0));
--- Begin processing.
--
next_render_Time := ada.Calendar.clock;
delay 1.0;
while not Done
loop
select
accept stop
do
Done := True;
end stop;
else
null;
end select;
the_World.evolve;
Counter := Counter + 1;
if Counter = 5 * 60
then
Counter := 0;
the_Ball.Site_is ((0.0, 25.0, 0.0));
end if;
next_render_Time := next_render_Time + gel.World.evolve_Period;
delay until next_render_Time;
end loop;
--- Close
--
the_World.destroy;
end;
exception
when E : others =>
put_Line ("Server unhandled exception ...");
put_Line (ada.exceptions.Exception_Information (E));
put_Line ("Server has terminated !");
end Item;
end gel_demo_Server;
|