From c6b6c708dbc390d2d30ef4a6a212973f84f92371 Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 26 Feb 2024 18:00:15 -0500 Subject: [PATCH] Added item rendering to world... --- source/world.adb | 25 ++++++++++++++++++++++++- source/world.ads | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/source/world.adb b/source/world.adb index c88a326..a81b9fb 100644 --- a/source/world.adb +++ b/source/world.adb @@ -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 -- <> 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); + -- + <> + end loop; end draw; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/world.ads b/source/world.ads index c3272f8..d5e72c5 100644 --- a/source/world.ads +++ b/source/world.ads @@ -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; ------------------------------------------------------------------------------------------