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

@ -28,16 +28,16 @@ package body world is
begin
core.echo (core.comment, "-- Procedurally generating new map...");
--
core.echo (core.comment, "-- -- Map type : " & index'image);
core.echo (core.comment, "-- -- Map width :" & width'image);
core.echo (core.comment, "-- -- Map height :" & height'image);
core.echo (core.comment, "-- -- Landmark count :" & landmark_limit'image);
core.echo (core.comment, "-- -- Map type : " & index'image);
core.echo (core.comment, "-- -- Map width :" & width'image);
core.echo (core.comment, "-- -- Map height :" & height'image);
core.echo (core.comment, "-- -- Landmark count :" & landmark_limit'image);
--
map.kind := index;
map.width := width;
map.height := height;
map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1);
map.landmarks := new landmark_array (1 .. landmark_limit);
map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1);
map.landmarks := new entity_array (1 .. landmark_limit);
--
for x in 0 .. width - 1 loop
for y in 0 .. height - 1 loop
@ -46,11 +46,12 @@ package body world is
end 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).y := core.random (0, map.height - 1);
end loop;
--
--
core.echo (core.success, "Finished procedurally generating new map.");
end make;
@ -94,7 +95,7 @@ package body world is
end 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,
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom);
end loop;

View File

@ -15,7 +15,8 @@ package world 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
@ -24,20 +25,21 @@ package world is
frames : integer;
end record;
type landmark_value is record
index : landmark_index;
type entity_trait is record
index : natural;
x, y : integer;
end record;
type tile_array is array (natural range <>, natural range <>) of integer;
type landmark_array is array (natural range <>) of landmark_value;
type tile_array is array (natural range <>, natural range <>) of integer;
type entity_array is array (natural range <>) of entity_trait;
type information is record
kind : biome;
width : natural;
height : natural;
tiles : access tile_array;
landmarks : access landmark_array;
kind : biome;
width : natural;
height : natural;
tiles : access tile_array;
landmarks : access entity_array;
constructions : access entity_array;
end record;
------------------------------------------------------------------------------------------