2024-04-25 00:27:13 -04:00
|
|
|
-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
|
|
|
|
--
|
|
|
|
-- GNU General Public Licence (version 3 or later)
|
|
|
|
|
2024-05-28 06:08:45 -04:00
|
|
|
with core, ui, attribute, skill, resource, material, faction, equipment;
|
2024-02-22 03:29:04 -05:00
|
|
|
|
|
|
|
package body chad is
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-16 12:35:36 -04:00
|
|
|
view_width : constant integer := 64;
|
|
|
|
view_height : constant integer := 96;
|
|
|
|
|
2024-05-19 02:59:45 -04:00
|
|
|
sprite : array (enumeration) of core.sprite;
|
|
|
|
view : array (enumeration) of core.sprite;
|
2024-04-23 16:19:29 -04:00
|
|
|
|
2024-05-01 14:41:55 -04:00
|
|
|
pepe_the_frog : core.sprite;
|
2024-05-03 05:28:44 -04:00
|
|
|
alice_the_mad : core.sprite;
|
2024-05-01 14:41:55 -04:00
|
|
|
|
2024-04-23 16:19:29 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-02-22 03:29:04 -05:00
|
|
|
procedure configure is
|
|
|
|
begin
|
2024-03-11 08:42:25 -04:00
|
|
|
core.echo (core.comment, "Configuring chad components...");
|
|
|
|
--
|
2024-05-19 02:59:45 -04:00
|
|
|
pepe_the_frog := core.import_sprite (core.folder & "/game/unit/pepe_the_frog.png", 4, 6);
|
|
|
|
alice_the_mad := core.import_sprite (core.folder & "/game/unit/alice_the_mad.png", 4, 6);
|
2024-05-01 14:41:55 -04:00
|
|
|
--
|
2024-04-27 10:01:54 -04:00
|
|
|
for index in enumeration loop
|
2024-05-19 02:59:45 -04:00
|
|
|
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);
|
2024-02-22 03:29:04 -05:00
|
|
|
null;
|
|
|
|
end loop;
|
|
|
|
end configure;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-06-01 11:56:18 -04:00
|
|
|
procedure draw (player : in information; x, y : in integer) is
|
2024-02-22 03:29:04 -05:00
|
|
|
begin
|
2024-05-16 14:52:41 -04:00
|
|
|
core.draw (sprite (player.index), x, y, state => player.state);
|
|
|
|
--
|
|
|
|
for index in equipment.slot loop
|
2024-05-17 18:35:31 -04:00
|
|
|
equipment.draw (player.equipments (index), player.state, x, y);
|
2024-05-16 14:52:41 -04:00
|
|
|
end loop;
|
2024-02-22 03:29:04 -05:00
|
|
|
end draw;
|
|
|
|
|
2024-05-01 14:41:55 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
2024-05-16 12:35:36 -04:00
|
|
|
|
2024-06-01 11:56:18 -04:00
|
|
|
procedure draw_data (player : in information; x, y : in integer) is
|
2024-05-16 13:17:36 -04:00
|
|
|
offset : constant integer := 8;
|
2024-05-11 00:28:50 -04:00
|
|
|
begin
|
2024-05-16 13:17:36 -04:00
|
|
|
ui.draw_frame ("--", x, y, 360 + 2 * offset, 96 + 2 * offset);
|
|
|
|
--
|
2024-06-01 11:27:59 -04:00
|
|
|
ui.draw_sprite (view (player.index), description (player.index).name, x + offset, y + offset, 0);
|
2024-05-16 13:17:36 -04:00
|
|
|
--
|
2024-06-01 12:39:44 -04:00
|
|
|
ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 1 * core.icon + offset, 360 - view_width - offset, float (player.health.value) / float (player.health.limit), (127, 0, 0, 255));
|
|
|
|
ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 2 * core.icon + offset, 360 - view_width - offset, float (player.mana.value) / float (player.mana.limit), (0, 0, 127, 255));
|
|
|
|
ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 3 * core.icon + offset, 360 - view_width - offset, float (player.movement.value) / float (player.movement.limit), (0, 127, 0, 255));
|
2024-05-16 13:17:36 -04:00
|
|
|
--
|
|
|
|
ui.write (text => "Health " & player.health.value'image & " /" & player.health.limit'image,
|
2024-05-20 15:30:40 -04:00
|
|
|
x => x + view_width + core.icon + 3 * offset,
|
2024-05-16 13:17:36 -04:00
|
|
|
y => y + 2 * offset,
|
|
|
|
tint => (255, 127, 127, 255),
|
|
|
|
size => 15,
|
|
|
|
code => true);
|
|
|
|
ui.write (text => "Mana " & player.mana.value'image & " /" & player.mana.limit'image,
|
2024-05-20 15:30:40 -04:00
|
|
|
x => x + view_width + core.icon + 3 * offset,
|
2024-05-16 13:17:36 -04:00
|
|
|
y => y + core.icon + 2 * offset,
|
|
|
|
tint => (127, 127, 255, 255),
|
|
|
|
size => 15,
|
|
|
|
code => true);
|
2024-06-01 12:39:44 -04:00
|
|
|
ui.write (text => "Stamina" & player.movement.value'image & " /" & player.movement.limit'image,
|
2024-05-20 15:30:40 -04:00
|
|
|
x => x + view_width + core.icon + 3 * offset,
|
2024-05-16 13:17:36 -04:00
|
|
|
y => y + 2 * core.icon + 2 * offset,
|
|
|
|
tint => (127, 255, 127, 255),
|
|
|
|
size => 15,
|
|
|
|
code => true);
|
|
|
|
--
|
2024-05-17 21:00:50 -04:00
|
|
|
attribute.draw_points (player.attributes, x, y + 96 + 3 * offset);
|
2024-05-17 19:37:52 -04:00
|
|
|
--
|
|
|
|
for index_y in 0 .. 3 loop
|
|
|
|
for index_x in 0 .. 5 loop
|
2024-05-19 02:59:45 -04:00
|
|
|
ui.draw_icon (data => equipment.icon (player.items (6 * index_y + index_x)),
|
2024-06-01 11:27:59 -04:00
|
|
|
text => equipment.description (player.items (6 * index_y + index_x)).name,
|
2024-05-17 19:37:52 -04:00
|
|
|
x => x + index_x * core.icon,
|
2024-05-17 21:00:50 -04:00
|
|
|
y => y + 96 + 4 * offset + 2 * core.icon + index_y * core.icon);
|
2024-05-17 19:37:52 -04:00
|
|
|
end loop;
|
|
|
|
end loop;
|
2024-05-17 21:00:50 -04:00
|
|
|
--
|
|
|
|
skill.draw_points (player.skills, x, y + 96 + 5 * offset + 6 * core.icon);
|
2024-05-11 00:28:50 -04:00
|
|
|
end draw_data;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-06-01 11:56:18 -04:00
|
|
|
procedure draw_menu (player : in information; x, y : in integer) is
|
2024-05-16 14:52:41 -04:00
|
|
|
begin
|
|
|
|
null;
|
|
|
|
end draw_menu;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-06-01 11:56:18 -04:00
|
|
|
function take_equipment_item (player : in out information; item : in equipment.enumeration) return boolean is
|
2024-05-19 02:59:45 -04:00
|
|
|
use type equipment.enumeration;
|
2024-05-17 18:35:31 -04:00
|
|
|
begin
|
2024-05-19 02:59:45 -04:00
|
|
|
if player.item_count = item_limit or item = equipment.none then
|
2024-05-17 18:35:31 -04:00
|
|
|
return false;
|
|
|
|
end if;
|
|
|
|
--
|
|
|
|
player.items (player.item_count) := item;
|
|
|
|
--
|
|
|
|
core.increment (player.item_count);
|
|
|
|
--
|
|
|
|
return true;
|
|
|
|
end take_equipment_item;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-01 14:41:55 -04:00
|
|
|
procedure draw_pepe is
|
|
|
|
begin
|
|
|
|
core.draw (pepe_the_frog, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
|
|
|
|
end draw_pepe;
|
|
|
|
|
2024-05-03 05:28:44 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure draw_alice is
|
|
|
|
begin
|
|
|
|
core.draw (alice_the_mad, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
|
|
|
|
end draw_alice;
|
|
|
|
|
2024-05-25 03:19:58 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-06-01 11:56:18 -04:00
|
|
|
procedure save_value (here : in core.io.file_type; data : in information) is
|
2024-05-25 03:19:58 -04:00
|
|
|
begin
|
|
|
|
core.io.write (here, enumeration'pos (data.index));
|
|
|
|
core.io.write (here, core.animation'pos (data.state));
|
|
|
|
core.io.write (here, data.x);
|
|
|
|
core.io.write (here, data.y);
|
|
|
|
--
|
|
|
|
core.save_point (here, data.health);
|
|
|
|
core.save_point (here, data.mana);
|
2024-06-01 12:39:44 -04:00
|
|
|
core.save_point (here, data.movement);
|
2024-05-25 03:19:58 -04:00
|
|
|
--
|
|
|
|
attribute.save_points (here, data.attributes);
|
|
|
|
skill.save_points (here, data.skills);
|
|
|
|
resource.save_points (here, data.resources);
|
2024-05-28 06:08:45 -04:00
|
|
|
material.save_points (here, data.materials);
|
2024-05-28 06:53:48 -04:00
|
|
|
--
|
|
|
|
for index in equipment.slot loop
|
|
|
|
core.io.write (here, equipment.enumeration'pos (data.equipments (index)));
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
core.io.write (here, data.item_count);
|
|
|
|
--
|
|
|
|
if data.item_count > 0 then
|
|
|
|
for index in 0 .. data.item_count - 1 loop
|
|
|
|
core.io.write (here, equipment.enumeration'pos (data.items (index)));
|
|
|
|
end loop;
|
|
|
|
end if;
|
2024-05-25 03:19:58 -04:00
|
|
|
end save_value;
|
|
|
|
|
2024-05-25 03:53:53 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-06-01 11:56:18 -04:00
|
|
|
procedure load_value (here : in core.io.file_type; data : out information) is
|
2024-05-25 03:53:53 -04:00
|
|
|
this : integer;
|
|
|
|
begin
|
|
|
|
core.io.read (here, this); data.index := enumeration'val (this);
|
|
|
|
core.io.read (here, this); data.state := core.animation'val (this);
|
|
|
|
core.io.read (here, data.x);
|
|
|
|
core.io.read (here, data.y);
|
|
|
|
--
|
|
|
|
core.load_point (here, data.health);
|
|
|
|
core.load_point (here, data.mana);
|
2024-06-01 12:39:44 -04:00
|
|
|
core.load_point (here, data.movement);
|
2024-05-25 03:53:53 -04:00
|
|
|
--
|
|
|
|
attribute.load_points (here, data.attributes);
|
|
|
|
skill.load_points (here, data.skills);
|
|
|
|
resource.load_points (here, data.resources);
|
2024-05-28 06:08:45 -04:00
|
|
|
material.load_points (here, data.materials);
|
2024-05-28 06:53:48 -04:00
|
|
|
--
|
|
|
|
for index in equipment.slot loop
|
|
|
|
core.io.read (here, this); data.equipments (index) := equipment.enumeration'val (this);
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
core.io.read (here, data.item_count);
|
|
|
|
--
|
|
|
|
if data.item_count > 0 then
|
|
|
|
for index in 0 .. data.item_count - 1 loop
|
|
|
|
core.io.read (here, this); data.items (index) := equipment.enumeration'val (this);
|
|
|
|
end loop;
|
|
|
|
end if;
|
2024-05-25 03:53:53 -04:00
|
|
|
end load_value;
|
|
|
|
|
2024-02-22 03:29:04 -05:00
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
end chad;
|