Changed Core package clipping...

This commit is contained in:
Ognjen Milan Robovic 2024-05-27 13:48:12 -04:00
parent 632916444f
commit 1a7c8e44d0
3 changed files with 29 additions and 25 deletions

View File

@ -168,12 +168,10 @@ package body core is
------------------------------------------------------------------------------------------
function clip (value, minimum, maximum : in integer) return integer is
procedure clip (value : in out integer; minimum, maximum : in integer) is
begin
if value < minimum then return minimum; end if;
if value > maximum then return maximum; end if;
--
return value;
if value < minimum then value := minimum; end if;
if value > maximum then value := maximum; end if;
end clip;
------------------------------------------------------------------------------------------

View File

@ -130,7 +130,8 @@ package core is
function c_string (ada_string : in string) return string;
function random (minimum, maximum : in integer) return integer;
function clip (value, minimum, maximum : in integer) return integer;
procedure clip (value : in out integer; minimum, maximum : in integer);
function lowercase (text : in string) return string;

View File

@ -89,7 +89,7 @@ package body world is
end loop;
end loop;
--
if core.animation_time = 0 then draw_tiles_timer := natural (1_000_000.0 * (core.time - time)); end if;
draw_tiles_timer := natural (1_000_000.0 * (core.time - time));
end draw_tiles;
------------------------------------------------------------------------------------------
@ -156,7 +156,7 @@ package body world is
end if;
end loop;
--
if core.animation_time = 0 then draw_landmarks_timer := natural (1_000_000.0 * (core.time - time)); end if;
draw_landmarks_timer := natural (1_000_000.0 * (core.time - time));
end draw_landmarks;
------------------------------------------------------------------------------------------
@ -204,7 +204,7 @@ package body world is
end if;
end loop;
--
if core.animation_time = 0 then draw_locations_timer := natural (1_000_000.0 * (core.time - time)); end if;
draw_locations_timer := natural (1_000_000.0 * (core.time - time));
end draw_locations;
------------------------------------------------------------------------------------------
@ -226,7 +226,7 @@ package body world is
end if;
end loop;
--
if core.animation_time = 0 then draw_constructions_timer := natural (1_000_000.0 * (core.time - time)); end if;
draw_constructions_timer := natural (1_000_000.0 * (core.time - time));
end draw_constructions;
------------------------------------------------------------------------------------------
@ -257,7 +257,7 @@ package body world is
end if;
end loop;
--
if core.animation_time = 0 then draw_equipments_timer := natural (1_000_000.0 * (core.time - time)); end if;
draw_equipments_timer := natural (1_000_000.0 * (core.time - time));
end draw_equipments;
------------------------------------------------------------------------------------------
@ -290,12 +290,12 @@ package body world is
end if;
end loop;
--
if core.animation_time = 0 then draw_units_timer := natural (1_000_000.0 * (core.time - time)); end if;
draw_units_timer := natural (1_000_000.0 * (core.time - time));
end draw_units;
------------------------------------------------------------------------------------------
procedure darken_map (offset, view_from, view_to : in core.vector) is
procedure compute_world_darkened_grid (offset, view_from, view_to : in core.vector) is
time : float := 0.0;
begin
time := core.time;
@ -316,8 +316,8 @@ package body world is
end loop;
end loop;
--
if core.animation_time = 0 then draw_views_timer := natural (1_000_000.0 * (core.time - time)); end if;
end darken_map;
draw_views_timer := natural (1_000_000.0 * (core.time - time));
end compute_world_darkened_grid;
------------------------------------------------------------------------------------------
@ -335,6 +335,10 @@ package body world is
if map.tiles (x, y) in 18 .. 23 and map.tiles (x, y + 1) not in 18 .. 23 then map.tiles (x, y + 1) := 25; end if;
if map.tiles (x, y) not in 18 .. 23 and map.tiles (x + 1, y ) in 18 .. 23 then map.tiles (x, y ) := 26; end if;
if map.tiles (x, y) in 18 .. 23 and map.tiles (x + 1, y ) not in 18 .. 23 then map.tiles (x + 1, y ) := 27; end if;
--~if matrix (1, 1) = 1 and map.tiles (x, y + 1) in 18 .. 23 then map.tiles (x, y ) := 24; end if;
--~if matrix (1, 1) = 0 and map.tiles (x, y + 1) not in 18 .. 23 then map.tiles (x, y + 1) := 25; end if;
--~if matrix (1, 1) = 1 and map.tiles (x + 1, y ) in 18 .. 23 then map.tiles (x, y ) := 26; end if;
--~if matrix (1, 1) = 0 and map.tiles (x + 1, y ) not in 18 .. 23 then map.tiles (x + 1, y ) := 27; end if;
--
if matrix = ((1, 1), (1, 0)) then map.tiles (x - 1, y - 1) := 28;
elsif matrix = ((1, 0), (1, 1)) then map.tiles (x, y - 1) := 29;
@ -640,10 +644,10 @@ package body world is
drawn_equipments := 0;
drawn_units := 0;
--
view_from.x := core.clip (view_from.x, 0, map.width - 1);
view_from.y := core.clip (view_from.y, 0, map.height - 1);
view_to.x := core.clip (view_to.x, 0, map.width - 1);
view_to.y := core.clip (view_to.y, 0, map.height - 1);
core.clip (view_from.x, 0, map.width - 1);
core.clip (view_from.y, 0, map.height - 1);
core.clip (view_to.x, 0, map.width - 1);
core.clip (view_to.y, 0, map.height - 1);
--
compute_world_visibility_grid (offset);
compute_world_frame (offset);
@ -654,9 +658,10 @@ package body world is
draw_constructions (offset, view_from, view_to);
draw_equipments (offset, view_from, view_to);
draw_units (offset, view_from, view_to);
darken_map (offset, view_from, view_to);
--
if core.animation_time = 0 then draw_world_timer := natural (1_000_000.0 * (core.time - time)); end if;
compute_world_darkened_grid (offset, view_from, view_to);
--
draw_world_timer := natural (1_000_000.0 * (core.time - time));
end draw;
------------------------------------------------------------------------------------------
@ -780,7 +785,7 @@ package body world is
procedure player_up is
begin
core.decrement (map.chads (1).y);
map.chads (1).y := core.clip (map.chads (1).y, 0, map.height - 1);
core.clip (map.chads (1).y, 0, map.height - 1);
if map.clips (map.chads (1).x, map.chads (1).y) then
core.increment (map.chads (1).y);
end if;
@ -791,7 +796,7 @@ package body world is
procedure player_down is
begin
core.increment (map.chads (1).y);
map.chads (1).y := core.clip (map.chads (1).y, 0, map.height - 1);
core.clip (map.chads (1).y, 0, map.height - 1);
if map.clips (map.chads (1).x, map.chads (1).y) then
core.decrement (map.chads (1).y);
end if;
@ -802,7 +807,7 @@ package body world is
procedure player_left is
begin
core.decrement (map.chads (1).x);
map.chads (1).x := core.clip (map.chads (1).x, 0, map.width - 1);
core.clip (map.chads (1).x, 0, map.width - 1);
if map.clips (map.chads (1).x, map.chads (1).y) then
core.increment (map.chads (1).x);
end if;
@ -813,7 +818,7 @@ package body world is
procedure player_right is
begin
core.increment (map.chads (1).x);
map.chads (1).x := core.clip (map.chads (1).x, 0, map.width - 1);
core.clip (map.chads (1).x, 0, map.width - 1);
if map.clips (map.chads (1).x, map.chads (1).y) then
core.decrement (map.chads (1).x);
end if;