Preparing World package for construction and item inclusion...

This commit is contained in:
Ognjen Milan Robovic 2024-05-05 11:38:15 -04:00
parent 381d088268
commit 6d997367d4
2 changed files with 21 additions and 18 deletions

View File

@ -37,7 +37,7 @@ package body world is
map.width := width; map.width := width;
map.height := height; map.height := height;
map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1); map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1);
map.landmarks := new landmark_array (1 .. landmark_limit); map.landmarks := new entity_array (1 .. landmark_limit);
-- --
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
@ -46,11 +46,12 @@ package body world is
end loop; end loop;
-- --
for index in 1 .. landmark_limit loop for index in 1 .. landmark_limit loop
map.landmarks (index).index := landmark_index'val (core.random (0, 8)); map.landmarks (index).index := core.random (0, 8);
map.landmarks (index).x := core.random (0, map.width - 1); map.landmarks (index).x := core.random (0, map.width - 1);
map.landmarks (index).y := core.random (0, map.height - 1); map.landmarks (index).y := core.random (0, map.height - 1);
end loop; end loop;
-- --
--
core.echo (core.success, "Finished procedurally generating new map."); core.echo (core.success, "Finished procedurally generating new map.");
end make; end make;
@ -94,7 +95,7 @@ package body world is
end loop; end loop;
-- --
for index in 1 .. landmark_limit loop for index in 1 .. landmark_limit loop
core.draw (data => landmarks (map.landmarks (index).index), core.draw (data => landmarks (landmark_index'val (map.landmarks (index).index)),
x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom, x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom); y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom);
end loop; end loop;

View File

@ -15,7 +15,8 @@ package world is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
type landmark_index is ( type landmark_index is (
dead_tree, mossy_rock, palm_tree, pine_tree, reeds, rock, snowed_pine_tree, snowed_rock, spiky_rock dead_tree, mossy_rock, palm_tree, pine_tree, reeds, rock,
snowed_pine_tree, snowed_rock, spiky_rock
); );
type landmark_trait is record type landmark_trait is record
@ -24,20 +25,21 @@ package world is
frames : integer; frames : integer;
end record; end record;
type landmark_value is record type entity_trait is record
index : landmark_index; index : natural;
x, y : integer; x, y : integer;
end record; end record;
type tile_array is array (natural range <>, natural range <>) of integer; type tile_array is array (natural range <>, natural range <>) of integer;
type landmark_array is array (natural range <>) of landmark_value; 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;
tiles : access tile_array; tiles : access tile_array;
landmarks : access landmark_array; landmarks : access entity_array;
constructions : access entity_array;
end record; end record;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------