From 6fe24956a53d30d1ae5f9a81389de334cad152da Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 9 Jun 2024 12:38:38 -0400 Subject: [PATCH] More experimental unit stuff... --- game/unit/elf/none.png | Bin 0 -> 125 bytes game/unit/human/none.png | Bin 0 -> 125 bytes game/unit/neutral/none.png | Bin 0 -> 125 bytes game/unit/orc/none.png | Bin 0 -> 125 bytes source/chad.ads | 6 ++---- source/main.adb | 18 +++++++++++++++- source/unit.ads | 52 +++++++++++++++++++++++++++------------------ source/world.adb | 35 ++++++++++++++++++------------ source/world.ads | 2 ++ 9 files changed, 74 insertions(+), 39 deletions(-) create mode 100644 game/unit/elf/none.png create mode 100644 game/unit/human/none.png create mode 100644 game/unit/neutral/none.png create mode 100644 game/unit/orc/none.png diff --git a/game/unit/elf/none.png b/game/unit/elf/none.png new file mode 100644 index 0000000000000000000000000000000000000000..6e5b3b4f3a620b494190b21c5cfcf3046075c4de GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^4nUm1!3HGP9xZtRq&N#aB8wRq^pruEv0|xx8BkE) x)5S5Q;?~=PhKxYop#@+4b9wm}0GZf8LpgIo0t4f*PjW3FX-`)_mvv4FO#l+p8MOca literal 0 HcmV?d00001 diff --git a/game/unit/human/none.png b/game/unit/human/none.png new file mode 100644 index 0000000000000000000000000000000000000000..6e5b3b4f3a620b494190b21c5cfcf3046075c4de GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^4nUm1!3HGP9xZtRq&N#aB8wRq^pruEv0|xx8BkE) x)5S5Q;?~=PhKxYop#@+4b9wm}0GZf8LpgIo0t4f*PjW3FX-`)_mvv4FO#l+p8MOca literal 0 HcmV?d00001 diff --git a/game/unit/neutral/none.png b/game/unit/neutral/none.png new file mode 100644 index 0000000000000000000000000000000000000000..6e5b3b4f3a620b494190b21c5cfcf3046075c4de GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^4nUm1!3HGP9xZtRq&N#aB8wRq^pruEv0|xx8BkE) x)5S5Q;?~=PhKxYop#@+4b9wm}0GZf8LpgIo0t4f*PjW3FX-`)_mvv4FO#l+p8MOca literal 0 HcmV?d00001 diff --git a/game/unit/orc/none.png b/game/unit/orc/none.png new file mode 100644 index 0000000000000000000000000000000000000000..6e5b3b4f3a620b494190b21c5cfcf3046075c4de GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^4nUm1!3HGP9xZtRq&N#aB8wRq^pruEv0|xx8BkE) x)5S5Q;?~=PhKxYop#@+4b9wm}0GZf8LpgIo0t4f*PjW3FX-`)_mvv4FO#l+p8MOca literal 0 HcmV?d00001 diff --git a/source/chad.ads b/source/chad.ads index 6fbcf94..ac431f9 100644 --- a/source/chad.ads +++ b/source/chad.ads @@ -2,7 +2,7 @@ -- -- GNU General Public Licence (version 3 or later) -with core, attribute, skill, resource, material, faction, equipment; +with core, attribute, skill, resource, material, faction, equipment, unit; package chad is @@ -16,7 +16,6 @@ package chad is item_limit : constant natural := 24; skill_limit : constant natural := 8; - --~unit_limit : constant natural := 8; type item_array is array (0 .. item_limit - 1) of equipment.enumeration; @@ -45,8 +44,7 @@ package chad is equipments : equipment.equip_array := equipment.default; item_count : natural := 0; items : item_array := (others => equipment.none); - --~unit_index : array (1 .. unit_limit) of unit.enumeration := (others => unit.none); - --~unit_count : array (1 .. unit_limit) of natural := (others => 0); + units : unit.points := (others => (others => <>)); end record; type informations is array (natural range <>) of information; diff --git a/source/main.adb b/source/main.adb index 3fef6fb..f0cb7b3 100644 --- a/source/main.adb +++ b/source/main.adb @@ -117,6 +117,11 @@ procedure main is equipment.feet => equipment.iron_greaves, equipment.main_hand => equipment.iron_sword, others => equipment.none), + -- + units => ((unit.dwarf_villager, 12, 120), + (unit.dwarf_knight, 3, 30), + others => <>), + -- others => <> ); @@ -235,6 +240,17 @@ procedure main is y => at_y + index_y * core.icon); end loop; end loop; + -- + at_y := at_y + 3 * core.icon; + -- + ui.draw_separator (at_x, at_y, width - 2 * offset); + -- + at_y := at_y + core.base; + -- + for index in 0 .. unit.limit - 1 loop + world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8); + ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon); + end loop; end player_information; ------------------------------------------------------------------------------------------ @@ -327,7 +343,7 @@ begin core.echo (core.comment, "Configuring" & unit.count'image & " unit components..."); -- - for index in faction.fairy .. faction.imp loop + for index in faction.enumeration loop unit.base (index) := core.import_sprite (core.folder & "/game/unit/" & core.lowercase (faction.enumeration'image (index)) & "/base.png", 4, 6); end loop; diff --git a/source/unit.ads b/source/unit.ads index 94d2aa5..9c913ce 100644 --- a/source/unit.ads +++ b/source/unit.ads @@ -17,9 +17,13 @@ package unit is ------------------------------------------------------------------------------------------ + limit : constant natural := 8; + count : constant natural := enumeration'pos (enumeration'last) + 1; + type definition is record name : access string := new string'("--"); kind : faction.enumeration := faction.neutral; + limit : natural := 0; attributes : attribute.bonus := (others => 0); hire_fee : natural := 0; weekly_fee : natural := 0; @@ -27,6 +31,14 @@ package unit is equipments : equipment.equip_array := equipment.default; end record; + type point is record + index : enumeration := none; + value : natural := 0; + limit : natural := 0; + end record; + + type points is array (0 .. limit - 1) of point; + --~bone_chestplate, bronze_chestplate, chainmail_chestplate, crystal_chestplate, golden_chestplate, iron_chestplate, --~leather_chestplate, mithril_chestplate, steel_chestplate, bone_greaves, bronze_greaves, chainmail_greaves, --~crystal_greaves, golden_greaves, iron_greaves, leather_greaves, mithril_greaves, steel_greaves, @@ -56,60 +68,58 @@ package unit is ------------------------------------------------------------------------------------------ - count : constant natural := enumeration'pos (enumeration'last) + 1; - description : constant array (enumeration) of definition := ( none => (others => <>), -- - dwarf_villager => (new string'("Villager"), faction.dwarf, (2, 1, 1, 1, 2, 1), 2, 1, 1, ( + dwarf_villager => (new string'("Villager"), faction.dwarf, 120, (2, 1, 1, 1, 2, 1), 2, 1, 1, ( equipment.grey_tunic, equipment.none, equipment.none, equipment.none, equipment.none, equipment.none, equipment.club, equipment.none)), - dwarf_miner => (new string'("Miner"), faction.dwarf, (2, 1, 1, 1, 2, 1), 2, 1, 1, ( + dwarf_miner => (new string'("Miner"), faction.dwarf, 120, (2, 1, 1, 1, 2, 1), 2, 1, 1, ( equipment.grey_tunic, equipment.none, equipment.none, equipment.fur_gauntlets, equipment.fur_greaves, equipment.none, equipment.pickaxe, equipment.none)), - dwarf_blacksmith => (new string'("Blacksmith"), faction.dwarf, (2, 1, 1, 1, 2, 1), 3, 1, 2, ( + dwarf_blacksmith => (new string'("Blacksmith"), faction.dwarf, 90, (2, 1, 1, 1, 2, 1), 3, 1, 2, ( equipment.grey_tunic, equipment.leather_helmet, equipment.none, equipment.leather_gauntlets, equipment.leather_greaves, equipment.none, equipment.sledge_hammer, equipment.none)), - dwarf_hunter => (new string'("Hunter"), faction.dwarf, (2, 1, 1, 1, 2, 1), 3, 2, 2, ( + dwarf_hunter => (new string'("Hunter"), faction.dwarf, 90, (2, 1, 1, 1, 2, 1), 3, 2, 2, ( equipment.grey_tunic, equipment.none, equipment.leather_chestplate, equipment.fur_gauntlets, equipment.fur_greaves, equipment.none, equipment.wooden_bow, equipment.none)), - dwarf_bowman => (new string'("Bowman"), faction.dwarf, (2, 1, 1, 1, 2, 1), 5, 3, 2, ( + dwarf_bowman => (new string'("Bowman"), faction.dwarf, 90, (2, 1, 1, 1, 2, 1), 5, 3, 2, ( equipment.blue_tunic, equipment.leather_helmet, equipment.iron_chestplate, equipment.none, equipment.leather_greaves, equipment.none, equipment.iron_bow, equipment.none)), - dwarf_warrior => (new string'("Warrior"), faction.dwarf, (2, 1, 1, 1, 2, 1), 7, 3, 3, ( + dwarf_warrior => (new string'("Warrior"), faction.dwarf, 120, (2, 1, 1, 1, 2, 1), 7, 3, 3, ( equipment.blue_tunic, equipment.leather_helmet, equipment.iron_chestplate, equipment.leather_gauntlets, equipment.leather_greaves, equipment.none, equipment.iron_mace, equipment.wooden_shield)), - dwarf_axeman => (new string'("Axeman"), faction.dwarf, (2, 1, 1, 1, 2, 1), 7, 3, 3, ( + dwarf_axeman => (new string'("Axeman"), faction.dwarf, 120, (2, 1, 1, 1, 2, 1), 7, 3, 3, ( equipment.blue_tunic, equipment.leather_helmet, equipment.iron_chestplate, equipment.leather_gauntlets, equipment.leather_greaves, equipment.none, equipment.iron_axe, equipment.wooden_shield)), - dwarf_crossbowman => (new string'("Crossbowman"), faction.dwarf, (2, 1, 1, 2, 2, 1), 7, 5, 3, ( + dwarf_crossbowman => (new string'("Crossbowman"), faction.dwarf, 90, (2, 1, 1, 2, 2, 1), 7, 5, 3, ( equipment.blue_tunic, equipment.iron_helmet, equipment.iron_chestplate, equipment.leather_gauntlets, equipment.leather_greaves, equipment.none, equipment.light_crossbow, equipment.none)), - dwarf_berserker => (new string'("Berserker"), faction.dwarf, (3, 2, 1, 3, 3, 1), 7, 3, 5, ( + dwarf_berserker => (new string'("Berserker"), faction.dwarf, 120, (3, 2, 1, 3, 3, 1), 7, 3, 5, ( equipment.blue_pants, equipment.none, equipment.none, equipment.leather_gauntlets, equipment.leather_greaves, equipment.none, equipment.iron_axe, equipment.none)), - dwarf_guard => (new string'("Guard"), faction.dwarf, (2, 3, 1, 3, 2, 1), 17, 5, 3, ( + dwarf_guard => (new string'("Guard"), faction.dwarf, 90, (2, 3, 1, 3, 2, 1), 17, 5, 3, ( equipment.cyan_tunic, equipment.iron_helmet, equipment.iron_chestplate, equipment.leather_gauntlets, equipment.leather_greaves, equipment.none, equipment.iron_spear, equipment.iron_shield)), - dwarf_elite_guard => (new string'("Elite Guard"), faction.dwarf, (3, 3, 1, 3, 2, 1), 23, 7, 2, ( + dwarf_elite_guard => (new string'("Elite Guard"), faction.dwarf, 90, (3, 3, 1, 3, 2, 1), 23, 7, 2, ( equipment.cyan_tunic, equipment.mithril_helmet, equipment.mithril_chestplate, equipment.steel_gauntlets, equipment.steel_greaves, equipment.none, equipment.mithril_spear, equipment.steel_shield)), - dwarf_war_druid => (new string'("War Druid"), faction.dwarf, (1, 1, 3, 1, 1, 1), 23, 3, 0, ( + dwarf_war_druid => (new string'("War Druid"), faction.dwarf, 60, (1, 1, 3, 1, 1, 1), 23, 3, 0, ( equipment.black_robe, equipment.black_hood, equipment.mithril_chestplate, equipment.none, equipment.none, equipment.none, equipment.staff_of_earth, equipment.none)), - dwarf_pig_rider => (new string'("Pig Rider"), faction.dwarf, others => <>), -- todo - dwarf_boar_rider => (new string'("Boar Rider"), faction.dwarf, others => <>), -- todo - dwarf_giant_mole_rider => (new string'("Giant Mole Rider"), faction.dwarf, others => <>), -- todo - dwarf_siegebowman => (new string'("Siegebowman"), faction.dwarf, others => <>), -- todo - dwarf_knight => (new string'("Knight"), faction.dwarf, (5, 3, 2, 3, 3, 1), 29, 7, 13, ( -- todo + dwarf_pig_rider => (new string'("Pig Rider"), faction.dwarf, 30, others => <>), -- todo + dwarf_boar_rider => (new string'("Boar Rider"), faction.dwarf, 30, others => <>), -- todo + dwarf_giant_mole_rider => (new string'("Giant Mole Rider"), faction.dwarf, 30, others => <>), -- todo + dwarf_siegebowman => (new string'("Siegebowman"), faction.dwarf, 60, others => <>), -- todo + dwarf_knight => (new string'("Knight"), faction.dwarf, 60, (5, 3, 2, 3, 3, 1), 29, 7, 13, ( -- todo equipment.cyan_robe, equipment.mithril_helmet, equipment.mithril_chestplate, equipment.mithril_gauntlets, equipment.mithril_greaves, equipment.none, equipment.mithril_battleaxe, equipment.mithril_shield)), - dwarf_flag_carrier => (new string'("Flag Carrier"), faction.dwarf, (5, 3, 2, 3, 5, 1), 29, 13, 0, ( + dwarf_flag_carrier => (new string'("Flag Carrier"), faction.dwarf, 10, (5, 3, 2, 3, 5, 1), 29, 13, 0, ( equipment.cyan_robe, equipment.mithril_helmet, equipment.mithril_chestplate, equipment.mithril_gauntlets, equipment.mithril_greaves, equipment.none, equipment.mithril_mace, equipment.mithril_shield)) ); - base : array (faction.fairy .. faction.imp) of core.sprite; + base : array (faction.enumeration) of core.sprite; --~icon : array (faction.fairy .. faction.imp) of core.sprite; --~view : array (faction.fairy .. faction.imp) of core.sprite; diff --git a/source/world.adb b/source/world.adb index 192bb9b..ef83c4a 100644 --- a/source/world.adb +++ b/source/world.adb @@ -335,6 +335,10 @@ package body world is end loop; end if; -- + for index in 0 .. unit.limit - 1 loop core.io.write (file, unit.enumeration'pos (map.chads (1).units (index).index)); end loop; + for index in 0 .. unit.limit - 1 loop core.io.write (file, map.chads (1).units (index).value); end loop; + for index in 0 .. unit.limit - 1 loop core.io.write (file, map.chads (1).units (index).limit); end loop; + -- core.io.close (file); -- core.echo (core.success, "Saved current map as '" & file_name & "'."); @@ -407,6 +411,10 @@ package body world is end loop; end if; -- + for index in 0 .. unit.limit - 1 loop core.io.read (file, this); map.chads (1).units (index).index := unit.enumeration'val (this); end loop; + for index in 0 .. unit.limit - 1 loop core.io.read (file, map.chads (1).units (index).value); end loop; + for index in 0 .. unit.limit - 1 loop core.io.read (file, map.chads (1).units (index).limit); end loop; + -- core.io.close (file); -- core.echo (core.success, "Loaded map from file '" & file_name & "'."); @@ -1023,6 +1031,17 @@ package body world is ------------------------------------------------------------------------------------------ + procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y : in integer) is + begin + core.draw (unit.base (unit.description (data).kind), x, y, state => state); + -- + for kind in equipment.kind loop + core.draw (equipment.sprite (unit.description (data).equipments (kind)), x, y, state => state); + end loop; + end draw_unit; + + ------------------------------------------------------------------------------------------ + procedure draw_units (offset, view_from, view_to : in core.vector) is time : float := 0.0; begin @@ -1032,20 +1051,10 @@ package body world is if map.views (map.units (index).x, map.units (index).y) and map.units (index).x > view_from.x and map.units (index).x < view_from.x + view_to.x and map.units (index).y > view_from.y and map.units (index).y < view_from.y + view_to.y then - core.draw (data => unit.base (unit.description (unit.enumeration'val (map.units (index).index)).kind), + draw_unit (data => unit.enumeration'val (map.units (index).index), + state => core.animation'val (map.units (index).state), x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, - y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom, - state => core.animation'val (map.units (index).state)); - -- - for kind in equipment.kind loop - if equipment.enumeration'pos (unit.description (unit.enumeration'val (map.units (index).index)).equipments (kind)) - /= equipment.enumeration'pos (equipment.none) then - core.draw (data => equipment.sprite (unit.description (unit.enumeration'val (map.units (index).index)).equipments (kind)), - x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, - y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom, - state => core.animation'val (map.units (index).state)); - end if; - end loop; + y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom); -- core.increment (drawn_units); end if; diff --git a/source/world.ads b/source/world.ads index da030cd..6adf038 100644 --- a/source/world.ads +++ b/source/world.ads @@ -229,6 +229,8 @@ package world is procedure add_chad (data : in chad.information); + procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y : in integer); + procedure resource_cheat_1; procedure resource_cheat_2; procedure resource_cheat_3;