Revised Unit package to use indexed arrays...

This commit is contained in:
Ognjen Milan Robovic 2024-05-11 01:45:06 -04:00
parent 572372a3bf
commit b71493497a
4 changed files with 14 additions and 12 deletions

View File

@ -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;

View File

@ -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;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -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);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -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;