text
stringlengths
0
234
-- Timer management
--
time_now := GLUT.Get (GLUT.ELAPSED_TIME); -- Number of milliseconds since GLUT.Init
if Self.all.new_scene then
Self.all.new_scene := False;
elaps := 0;
else
elaps := time_now - Self.all.last_time;
end if;
Self.all.last_time := time_now;
Self.all.Average := 0.0;
for i in reverse Self.all.sample'First + 1 .. Self.all.sample'Last loop
Self.all.sample (i) := Self.all.sample (i - 1);
Self.all.Average := Self.all.Average + Real (Self.all.sample (i));
end loop;
Self.all.sample (Self.all.sample'First) := elaps;
Self.all.Average := Self.all.Average + Real (elaps);
Self.all.Average := Self.all.Average / Real (Self.all.sample'Length);
seconds := Real (elaps) * 0.001;
attenu_t := Real'Min (0.96, Real'Max (0.04, 1.0 - seconds * 4.0));
attenu_r := attenu_t ** 0.5;
-- Game control management
--
Self.all.game_command := no_command;
Game_Control.Append_Commands (size_x => Integer (Self.all.main_size_x),
size_y => Integer (Self.all.main_size_y),
warp_mouse => Self.all.full_screen,
c => Self.all.game_command,
gx => gx,
gy => gy,
Keyboard => Self.all.Keyboard'Access,
Mouse => Self.all.Mouse'Access);
if Self.all.forget_mouse > 0 then -- mouse coords disturbed by resize
gx := 0.0;
gy := 0.0;
Self.all.forget_mouse := Self.all.forget_mouse - 1;
end if;
if Self.all.game_command (interrupt_game) then
null; -- GLUT_exit; -- tbd : how to handle this best ?
end if;
alpha_correct := False;
if Self.all.game_command (special_plus) then
Self.all.Alpha := Self.all.Alpha + seconds; alpha_correct := True;
end if;
if Self.all.game_command (special_minus) then
Self.all.Alpha := Self.all.Alpha - seconds; alpha_correct := True;
end if;
if alpha_correct then
if Self.all.Alpha < 0.0 then
Self.all.Alpha := 0.0;
elsif Self.all.Alpha > 1.0 then
Self.all.Alpha := 1.0;
end if;
for Each in 1 .. Self.all.object_Count loop
set_Alpha (Self.all.Objects (Each).all, Self.all.Alpha);
end loop;
end if;
-- Camera/Eye - nb : camera movement is done after rendering, so camera is in a state ready for the next frame.
-- - (important for Impostors)
-- Rotating the eye
Actors.Rotation (Self.all.Camera,
gc => Self.all.game_command,
gx => gx,
gy => gy,
unitary_change => seconds,
deceleration => attenu_r,
time_step => time_Step);
-- Moving the eye
Actors.Translation (Self.all.Camera,
gc => Self.all.game_command,
gx => gx,
gy => gy,
unitary_change => seconds,
deceleration => attenu_t,
time_step => time_Step);
if Self.all.game_command (n0) then
Reset_eye (Self.all);
end if;
Self.all.Camera.Clipper.view_direction := Transpose (Self.all.Camera.World_Rotation) * (0.0, 0.0, -1.0);