Implementing HoM&M3-like water due to performance...

This commit is contained in:
Ognjen Milan Robovic 2024-05-19 07:23:55 -04:00
parent dc45310370
commit c4ac4e759c
2 changed files with 42 additions and 34 deletions

View File

@ -16,7 +16,7 @@ package body world is
chad_limit : constant natural := 8; chad_limit : constant natural := 8;
earth : core.sprite; earth : core.sprite;
water : core.sprite; --~water : core.sprite;
dark : core.sprite; dark : core.sprite;
border_upper : core.sprite; border_upper : core.sprite;
border_lower : core.sprite; border_lower : core.sprite;
@ -34,7 +34,7 @@ package body world is
core.echo (core.comment, "Configuring world components..."); core.echo (core.comment, "Configuring world components...");
-- --
earth := core.import_sprite (core.folder & "/game/world/terrain/earth.png", 1, 1); earth := core.import_sprite (core.folder & "/game/world/terrain/earth.png", 1, 1);
water := core.import_sprite (core.folder & "/game/world/terrain/water.png", 1, 1); --~water := core.import_sprite (core.folder & "/game/world/terrain/water.png", 1, 1);
dark := core.import_sprite (core.folder & "/game/world/dark.png", 1, 1); dark := core.import_sprite (core.folder & "/game/world/dark.png", 1, 1);
border_upper := core.import_sprite (core.folder & "/game/world/frame/border_upper.png", 1, 1); border_upper := core.import_sprite (core.folder & "/game/world/frame/border_upper.png", 1, 1);
border_lower := core.import_sprite (core.folder & "/game/world/frame/border_lower.png", 1, 1); border_lower := core.import_sprite (core.folder & "/game/world/frame/border_lower.png", 1, 1);
@ -69,8 +69,8 @@ package body world is
map.height := height; map.height := height;
-- --
map.earth := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1); map.earth := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.water := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1); --~map.water := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.is_water := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1); --~map.is_water := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.clips := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1); map.clips := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.views := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1); map.views := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.landmarks := new entity_array (1 .. landmark_limit); map.landmarks := new entity_array (1 .. landmark_limit);
@ -83,13 +83,26 @@ package body world is
for x in 0 .. width - 1 loop for x in 0 .. width - 1 loop
for y in 0 .. height - 1 loop for y in 0 .. height - 1 loop
map.earth (x, y) := (if core.random (0, 23) < 19 then core.random (0, 11) else core.random (0, 23)); map.earth (x, y) := (if core.random (0, 23) < 19 then core.random (0, 11) else core.random (0, 23));
map.is_water (x, y) := (if core.random (0, 31) = 19 then true else false); --~map.is_water (x, y) := (if x > 9 and x < width - 9 and y > 9 and y < height - 9 then core.random (0, 1023) = 0 else false);
map.water (x, y) := (if map.is_water (x, y) then core.random (0, 7) else 0); --~map.water (x, y) := (if map.is_water (x, y) then core.random (0, 7) else 0);
map.clips (x, y) := false; map.clips (x, y) := false;
map.views (x, y) := false; map.views (x, y) := false;
end loop; end loop;
end loop; end loop;
-- --
--~for x in 9 .. width - 9 loop
--~for y in 9 .. height - 9 loop
--~if map.is_water (x, y) then
--~for extend_x in -3 .. 3 loop
--~for extend_y in -2 .. 2 loop
--~map.is_water (extend_x + x, extend_y + y) := core.random (0, 3) /= 0;
--~map.water (extend_x + x, extend_y + y) := (if map.is_water (extend_x + x, extend_y + y) then core.random (0, 7) else 0);
--~end loop;
--~end loop;
--~end if;
--~end loop;
--~end loop;
--
for index in 1 .. landmark_limit loop for index in 1 .. landmark_limit loop
map.landmarks (index).index := core.random (0, landmark_count - 1); map.landmarks (index).index := core.random (0, landmark_count - 1);
map.landmarks (index).x := core.random (6, map.width - 6); map.landmarks (index).x := core.random (6, map.width - 6);
@ -190,26 +203,26 @@ package body world is
v => core.base * map.earth (horizontal, vertical), v => core.base * map.earth (horizontal, vertical),
width => core.base, width => core.base,
height => core.base); height => core.base);
if map.is_water (horizontal, vertical) then --~if map.is_water (horizontal, vertical) then
core.draw (data => water, --~core.draw (data => water,
x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom, --~x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
y => offset.y + (vertical - core.camera.y) * core.base * core.zoom, --~y => offset.y + (vertical - core.camera.y) * core.base * core.zoom,
u => core.base * biome'pos (map.kind) * 4 + (core.animation_time mod 4) * core.base, --~u => core.base * biome'pos (map.kind) * 4 + (core.animation_time mod 4) * core.base,
v => core.base * map.water (horizontal, vertical), --~v => core.base * map.water (horizontal, vertical),
width => core.base, --~width => core.base,
height => core.base); --~height => core.base);
end if; --~end if;
-- --~--
if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6 --~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6
and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6 --~and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6
and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - 6 --~and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - 6
and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom + 6 --~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom + 6
and core.cursor_mode = 1 --~and core.cursor_mode = 1
and not ui.prioritize then --~and not ui.prioritize then
core.camera.x := horizontal; --~core.camera.x := horizontal;
core.camera.y := vertical; --~core.camera.y := vertical;
core.cursor_mode := 0; --~core.cursor_mode := 0;
end if; --~end if;
end if; end if;
end loop; end loop;
end loop; end loop;
@ -250,12 +263,7 @@ package body world is
and map.equipments (index).y = core.camera.y and map.equipments (index).y = core.camera.y
and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e) then and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e) then
if chad.take_equipment_item (map.chad_data (1), equipment.enumeration'val (map.equipments (index).index)) then if chad.take_equipment_item (map.chad_data (1), equipment.enumeration'val (map.equipments (index).index)) then
--~core.echo (core.comment, "Took item: " & equipment.trait (equipment.enumeration'val (map.equipments (index).index)).name);
--
map.equipments (index).index := equipment.enumeration'pos (equipment.none); map.equipments (index).index := equipment.enumeration'pos (equipment.none);
--~map.equipments (index).index := 0;
--~else
--~core.echo (core.warning, "Nope item: " & equipment.trait (equipment.enumeration'val (map.equipments (index).index)).name);
end if; end if;
end if; end if;
end loop; end loop;

View File

@ -35,15 +35,15 @@ package world is
type integer_matrix is array (natural range <>, natural range <>) of integer; type integer_matrix is array (natural range <>, natural range <>) of integer;
type boolean_matrix is array (natural range <>, natural range <>) of boolean; type boolean_matrix is array (natural range <>, natural range <>) of boolean;
type entity_array is array (natural range <>) of entity_trait; type entity_array is array (natural range <>) of entity_trait;
type information is record type information is record
kind : biome; kind : biome;
width : natural; width : natural;
height : natural; height : natural;
earth : access integer_matrix; earth : access integer_matrix;
water : access integer_matrix; --~water : access integer_matrix;
is_water : access boolean_matrix; --~is_water : access boolean_matrix;
clips : access boolean_matrix; clips : access boolean_matrix;
views : access boolean_matrix; views : access boolean_matrix;
landmarks : access entity_array; landmarks : access entity_array;