Added item rendering to world...

This commit is contained in:
Ognjen Milan Robovic 2024-02-26 18:00:15 -05:00
parent 4abc465194
commit c6b6c708db
2 changed files with 25 additions and 1 deletions

View File

@ -23,7 +23,8 @@ package body world is
limit : constant limit_array := (29, 64, 70, 94, 51, 94);
landmark_limit : constant integer := 140;
construction_limit : constant integer := 10;
construction_limit : constant integer := 40;
item_limit : constant integer := 40;
------------------------------------------------------------------------------------------
@ -56,6 +57,7 @@ package body world is
map.block := new block_array (0 .. width - 1, 0 .. height - 1);
map.landmark := new entity_array (0 .. landmark_limit);
map.construction := new entity_array (0 .. construction_limit);
map.item := new entity_array (0 .. item_limit);
--
for x in 0 .. width - 1
loop
@ -78,6 +80,13 @@ package body world is
map.construction (object).x := core.base * core.random_integer (1, map.width - 1);
map.construction (object).y := core.base * core.random_integer (1, map.height - 1);
end loop;
--
for object in 0 .. item_limit
loop
map.item (object).index := core.random_integer (0, item.codex'pos (item.codex'last));
map.item (object).x := core.base * core.random_integer (1, map.width - 1);
map.item (object).y := core.base * core.random_integer (1, map.height - 1);
end loop;
end make;
------------------------------------------------------------------------------------------
@ -142,6 +151,20 @@ package body world is
--
<<skip_drawing_out_of_view_construction>>
end loop;
--
for object in 0 .. item_limit
loop
if map.item (object).x > width
or map.item (object).y > height then
goto skip_drawing_out_of_view_item;
end if;
--
item.draw (item.codex'val (map.item (object).index),
map.item (object).x - core.camera.x * core.base,
map.item (object).y - core.camera.y * core.base);
--
<<skip_drawing_out_of_view_item>>
end loop;
end draw;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -26,6 +26,7 @@ package world is
block : access block_array;
landmark : access entity_array;
construction : access entity_array;
item : access entity_array;
end record;
------------------------------------------------------------------------------------------