From b71493497a809dc77eb9598a522a84783bf98801 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sat, 11 May 2024 01:45:06 -0400 Subject: [PATCH] Revised Unit package to use indexed arrays... --- source/main.adb | 4 ++-- source/unit.adb | 12 ++++++------ source/unit.ads | 8 +++++--- source/world.adb | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/source/main.adb b/source/main.adb index 47255e1..fe189c3 100644 --- a/source/main.adb +++ b/source/main.adb @@ -23,7 +23,7 @@ procedure main is player : chad.data := ( index => chad.ognjen, attributes => (1, 2, 3, 4, 5, 6), - skills => (1, 2, 3, 4, 5, 6, others => 12), + skills => (1, 2, 3, 4, 5, 6, 7, 8, 9, others => 0), resources => (1, 2, 3, 4, 5, 6) ); @@ -194,7 +194,7 @@ begin ui.configure; - play (import_song (c_string ("./song/main_menu.ogg")).index); + --~play (import_song (c_string ("./song/main_menu.ogg")).index); attribute.configure; skill.configure; diff --git a/source/unit.adb b/source/unit.adb index 65263a4..b476613 100644 --- a/source/unit.adb +++ b/source/unit.adb @@ -57,16 +57,16 @@ package body unit is ------------------------------------------------------------------------------------------ - procedure full_draw (data : in value; x, y : in integer) is + procedure draw_data (index : in natural; x, y : in integer) is begin - draw (data.kind, data.state, x, y); + draw (list (index).kind, list (index).state, x, y); -- - for index in item.slot loop - if data.items (index).allow then - item.draw (data.items (index).index, data.state, x, y); + for item_index in item.slot loop + if list (index).items (item_index).allow then + item.draw (list (index).items (item_index).index, list (index).state, x, y); end if; end loop; - end full_draw; + end draw_data; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/unit.ads b/source/unit.ads index f9f7014..29973e6 100644 --- a/source/unit.ads +++ b/source/unit.ads @@ -22,7 +22,7 @@ package unit is text : core.long_string; end record; - type value is record + type data is record kind : enumeration; state : core.animation; attributes : attribute.points; @@ -30,6 +30,8 @@ package unit is items : item.list; end record; + type data_array is array (0 .. 100) of data; + ------------------------------------------------------------------------------------------ count : constant natural := enumeration'pos (enumeration'last) + 1; @@ -43,7 +45,7 @@ package unit is ("Kobold ", faction.kobold, (others => 1), effect.none, " ") ); - list : array (0 .. 100) of value := ( + list : data_array := ( others => (dwarf_base, core.idle, (others => 1), ( item.main_hand => (item.iron_sword, true), item.full_body => (item.cyan_tunic, true), @@ -60,7 +62,7 @@ package unit is procedure icon (index : in enumeration; x, y : in integer); procedure view (index : in enumeration; x, y : in integer); - procedure full_draw (data : in value; x, y : in integer); + procedure draw_data (index : in natural; x, y : in integer); ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index 66db30c..57ba979 100644 --- a/source/world.adb +++ b/source/world.adb @@ -221,7 +221,7 @@ package body world is -- for index in 1 .. 90 loop if map.views (map.units (index).x, map.units (index).y) then - unit.full_draw (unit.list (map.units (index).index), + unit.draw_data (map.units (index).index, offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom); end if;