More refactoring of Chad package...

This commit is contained in:
Ognjen Milan Robovic 2024-06-03 16:06:31 -04:00
parent aee1412d57
commit 31f07b9ebe
4 changed files with 24 additions and 39 deletions

View File

@ -8,38 +8,6 @@ package body chad is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
view_width : constant integer := 64;
view_height : constant integer := 96;
sprite : array (enumeration) of core.sprite;
view : array (enumeration) of core.sprite;
------------------------------------------------------------------------------------------
procedure configure is
begin
core.echo (core.comment, "Configuring chad components...");
--
for index in enumeration loop
sprite (index) := core.import_sprite (core.folder & "/game/chad/" & core.lowercase (enumeration'image (index)) & ".png", 4, 6);
view (index) := core.import_sprite (core.folder & "/view/chad/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);
null;
end loop;
end configure;
------------------------------------------------------------------------------------------
procedure draw (player : in information; x, y : in integer) is
begin
core.draw (sprite (player.index), x, y, state => player.state);
--
for index in equipment.slot loop
core.draw (equipment.sprite (player.equipments (index)), x, y, state => player.state);
end loop;
end draw;
------------------------------------------------------------------------------------------
procedure draw_data (player : in information; x, y : in integer) is procedure draw_data (player : in information; x, y : in integer) is
offset : constant integer := 8; offset : constant integer := 8;
begin begin

View File

@ -60,11 +60,14 @@ package chad is
marina => ("Marina Ann Hantzis ", faction.imp, attribute.reach, skill.necromancy, resource.gold) marina => ("Marina Ann Hantzis ", faction.imp, attribute.reach, skill.necromancy, resource.gold)
); );
view_width : constant integer := 64;
view_height : constant integer := 96;
sprite : array (enumeration) of core.sprite;
view : array (enumeration) of core.sprite;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure configure;
procedure draw (player : in information; x, y : in integer);
procedure draw_data (player : in information; x, y : in integer); procedure draw_data (player : in information; x, y : in integer);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -264,7 +264,13 @@ begin
end; end;
end loop; end loop;
chad.configure; core.echo (core.comment, "Configuring" & chad.count'image & "chad components...");
--
for index in chad.enumeration loop
chad.sprite (index) := core.import_sprite (core.folder & "/game/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 4, 6);
chad.view (index) := core.import_sprite (core.folder & "/view/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 1, 1);
end loop;
world.configure; world.configure;
--~ai.configure; --~ai.configure;

View File

@ -405,9 +405,17 @@ package body world is
-- --
for index in 1 .. map.chad_count loop for index in 1 .. map.chad_count loop
if map.views (map.chads (index).x, map.chads (index).y) then if map.views (map.chads (index).x, map.chads (index).y) then
chad.draw (map.chads (index), core.draw (data => chad.sprite (map.chads (index).index),
offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom, x => offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom,
offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom); y => offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom,
state => map.chads (index).state);
--
for slot in equipment.slot loop
core.draw (data => equipment.sprite (map.chads (index).equipments (slot)),
x => offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom,
state => map.chads (index).state);
end loop;
-- --
core.increment (drawn_units); core.increment (drawn_units);
end if; end if;