@@ -40,9 +40,7 @@ package body chad is | |||
core.draw (sprite (player.index), x, y, state => player.state); | |||
-- | |||
for index in equipment.slot loop | |||
if player.equipments (index).show then | |||
equipment.draw (player.equipments (index).data, player.state, x, y); | |||
end if; | |||
equipment.draw (player.equipments (index), player.state, x, y); | |||
end loop; | |||
end draw; | |||
@@ -98,6 +96,21 @@ package body chad is | |||
------------------------------------------------------------------------------------------ | |||
function take_equipment_item (player : in out data; item : in equipment.enumeration) return boolean is | |||
begin | |||
if player.item_count = item_limit - 1 then | |||
return false; | |||
end if; | |||
-- | |||
player.items (player.item_count) := item; | |||
-- | |||
core.increment (player.item_count); | |||
-- | |||
return true; | |||
end take_equipment_item; | |||
------------------------------------------------------------------------------------------ | |||
procedure draw_pepe is | |||
begin | |||
core.draw (pepe_the_frog, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2); | |||
@@ -22,6 +22,10 @@ package chad is | |||
bonus_resource : resource.enumeration; | |||
end record; | |||
item_limit : constant natural := 24; | |||
type item_array is array (0 .. item_limit - 1) of equipment.enumeration; | |||
type data is record | |||
index : enumeration; | |||
state : core.animation; | |||
@@ -31,9 +35,13 @@ package chad is | |||
attributes : attribute.points; | |||
skills : skill.points; | |||
resources : resource.points; | |||
equipments : equipment.equip_array := (others => equipment.empty); | |||
equipments : equipment.equip_array; | |||
item_count : natural; | |||
items : item_array; | |||
end record; | |||
type data_list is array (natural range <>) of data; | |||
------------------------------------------------------------------------------------------ | |||
count : constant natural := enumeration'pos (enumeration'last) + 1; | |||
@@ -56,6 +64,8 @@ package chad is | |||
procedure draw_data (player : in data; x, y : in integer); | |||
procedure draw_menu (player : in data; x, y : in integer); | |||
function take_equipment_item (player : in out data; item : in equipment.enumeration) return boolean; | |||
procedure draw_pepe; | |||
procedure draw_alice; | |||
@@ -25,6 +25,10 @@ package body equipment is | |||
procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is | |||
begin | |||
if index = none then | |||
return; | |||
end if; | |||
-- | |||
core.draw (sprite (index), x, y, state => state); | |||
end draw; | |||
@@ -14,6 +14,7 @@ package equipment is | |||
); | |||
type enumeration is ( | |||
none, | |||
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, | |||
@@ -49,20 +50,14 @@ package equipment is | |||
evoke : effect.enumeration; | |||
end record; | |||
type value is record | |||
data : enumeration := equipment.lime_hood; | |||
show : boolean := true; | |||
end record; | |||
type equip_array is array (slot) of value; | |||
type equip_array is array (slot) of enumeration; | |||
------------------------------------------------------------------------------------------ | |||
empty : constant value := (equipment.lime_hood, false); | |||
count : constant natural := enumeration'pos (enumeration'last) + 1; | |||
trait : constant array (enumeration) of information := ( | |||
none => ("-- ", full_body, (0, 0, 0, 0, 0, 0), faction.neutral, effect.none), | |||
bone_chestplate => ("Bone Chestplate ", chest, (0, 0, 0, 0, 0, 0), faction.neutral, effect.none), | |||
bronze_chestplate => ("Bronze Chestplate ", chest, (0, 0, 0, 0, 0, 0), faction.neutral, effect.none), | |||
chainmail_chestplate => ("Chainmail Chestplate ", chest, (0, 0, 0, 0, 0, 0), faction.neutral, effect.none), | |||
@@ -30,12 +30,14 @@ procedure main is | |||
attributes => (1, 2, 3, 4, 5, 6), | |||
skills => (1, 2, 3, 4, 5, 6, 7, 8, 9, others => 0), | |||
resources => (101, 103, 107, 109, 113, 127), | |||
equipments => (equipment.chest => (equipment.elven_armour, true), | |||
--~equipment.head => (equipment.elven_helmet, true), | |||
equipment.hands => (equipment.leather_gauntlets, true), | |||
equipment.feet => (equipment.leather_greaves, true), | |||
equipment.main_hand => (equipment.jade_sword, true), | |||
others => (equipment.empty)) | |||
equipments => (equipment.chest => equipment.elven_armour, | |||
--~equipment.head => equipment.elven_helmet, | |||
equipment.hands => equipment.leather_gauntlets, | |||
equipment.feet => equipment.leather_greaves, | |||
equipment.main_hand => equipment.jade_sword, | |||
others => equipment.none), | |||
item_count => 0, | |||
items => (others => equipment.none) | |||
); | |||
------------------------------------------------------------------------------------------ | |||
@@ -217,6 +219,8 @@ begin | |||
world.make (world.grass, 240, 180); | |||
world.add_chad (player, (0, 0, 0)); | |||
dash; | |||
echo (success, "Successfully initialized game data, entering main gameplay loop."); | |||
dash; | |||
@@ -331,7 +335,7 @@ begin | |||
ui.synchronize; | |||
end loop gameplay_loop; | |||
world.mapshot ("./test.png"); | |||
--~world.mapshot ("./test.png"); | |||
------------------------------------------------------------------------------------------ | |||
@@ -63,9 +63,7 @@ package body unit is | |||
draw (values (limit).kind, values (limit).state, x, y); | |||
-- | |||
for equipment_index in equipment.slot loop | |||
if values (limit).equipments (equipment_index).show then | |||
equipment.draw (values (limit).equipments (equipment_index).data, values (limit).state, x, y); | |||
end if; | |||
equipment.draw (values (limit).equipments (equipment_index), values (limit).state, x, y); | |||
end loop; | |||
end draw_full; | |||
@@ -27,7 +27,7 @@ package unit is | |||
kind : enumeration := imp_base; | |||
state : core.animation := core.idle; | |||
attributes : attribute.points := (others => 0); | |||
equipments : equipment.equip_array := (others => equipment.empty); | |||
equipments : equipment.equip_array := (others => equipment.none); | |||
end record; | |||
type value_limit is range 0 .. 90; | |||
@@ -49,17 +49,9 @@ package unit is | |||
default_value : value; | |||
values : value_array := ( | |||
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), | |||
(equipment.main_hand => (equipment.mithril_axe, true), | |||
others => equipment.empty)), | |||
-- | |||
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), | |||
(equipment.main_hand => (equipment.mithril_battleaxe, true), | |||
others => equipment.empty)), | |||
-- | |||
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), | |||
(equipment.main_hand => (equipment.mithril_mace, true), | |||
others => equipment.empty)), | |||
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), (equipment.main_hand => equipment.mithril_axe, others => equipment.none)), | |||
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), (equipment.main_hand => equipment.mithril_battleaxe, others => equipment.none)), | |||
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), (equipment.main_hand => equipment.mithril_mace, others => equipment.none)), | |||
-- | |||
others => default_value | |||
); | |||
@@ -2,7 +2,7 @@ | |||
-- | |||
-- GNU General Public Licence (version 3 or later) | |||
with core, ui, resource, equipment, unit, construction; | |||
with core, ui, resource, equipment, unit, construction, chad; | |||
package body world is | |||
@@ -13,6 +13,7 @@ package body world is | |||
construction_limit : constant natural := 120; | |||
equipment_limit : constant natural := 600; | |||
unit_limit : constant natural := 600; | |||
chad_limit : constant natural := 8; | |||
dark : core.sprite; | |||
border_upper : core.sprite; | |||
@@ -64,13 +65,15 @@ package body world is | |||
map.width := width; | |||
map.height := height; | |||
-- | |||
map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1); | |||
map.clips := new clip_array (0 .. map.width - 1, 0 .. map.height - 1); | |||
map.views := new view_array (0 .. map.width - 1, 0 .. map.height - 1); | |||
map.landmarks := new entity_array (1 .. landmark_limit); | |||
map.constructions := new entity_array (1 .. construction_limit); | |||
map.equipments := new entity_array (1 .. equipment_limit); | |||
map.units := new entity_array (1 .. unit_limit); | |||
map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1); | |||
map.clips := new clip_array (0 .. map.width - 1, 0 .. map.height - 1); | |||
map.views := new view_array (0 .. map.width - 1, 0 .. map.height - 1); | |||
map.landmarks := new entity_array (1 .. landmark_limit); | |||
map.constructions := new entity_array (1 .. construction_limit); | |||
map.equipments := new entity_array (1 .. equipment_limit); | |||
map.units := new entity_array (1 .. unit_limit); | |||
map.chads := new entity_array (1 .. chad_limit); | |||
map.chad_data := new chad.data_list (1 .. chad_limit); | |||
-- | |||
for x in 0 .. width - 1 loop | |||
for y in 0 .. height - 1 loop | |||
@@ -231,6 +234,16 @@ package body world is | |||
offset.x + (map.equipments (index).x - core.camera.x) * core.base * core.zoom, | |||
offset.y + (map.equipments (index).y - core.camera.y) * core.base * core.zoom); | |||
end if; | |||
-- | |||
if map.equipments (index).x = core.camera.x | |||
and map.equipments (index).y = core.camera.y | |||
and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e) then | |||
if chad.take_equipment_item (map.chad_data (1), equipment.enumeration'val (map.equipments (index).index)) then | |||
core.echo (core.comment, "Took item: " & equipment.trait (equipment.enumeration'val (map.equipments (index).index)).name); | |||
else | |||
core.echo (core.warning, "Nope item: " & equipment.trait (equipment.enumeration'val (map.equipments (index).index)).name); | |||
end if; | |||
end if; | |||
end loop; | |||
-- | |||
for index in 1 .. unit_limit loop | |||
@@ -322,6 +335,14 @@ package body world is | |||
end loop; | |||
end reveal_map; | |||
------------------------------------------------------------------------------------------ | |||
procedure add_chad (data : in chad.data; entity : in entity_trait) is | |||
begin | |||
map.chads (1) := entity; | |||
map.chad_data (1) := data; | |||
end add_chad; | |||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |||
end world; |
@@ -2,7 +2,7 @@ | |||
-- | |||
-- GNU General Public Licence (version 3 or later) | |||
with core, equipment, unit, construction; | |||
with core, equipment, unit, construction, chad; | |||
package world is | |||
@@ -49,6 +49,8 @@ package world is | |||
constructions : access entity_array; | |||
equipments : access entity_array; | |||
units : access entity_array; | |||
chads : access entity_array; | |||
chad_data : access chad.data_list; | |||
end record; | |||
------------------------------------------------------------------------------------------ | |||
@@ -102,6 +104,8 @@ package world is | |||
procedure reveal_map; | |||
procedure add_chad (data : in chad.data; entity : in entity_trait); | |||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |||
end world; |