Prototype game engine for Heroes of Might & Magic, featuring a gameplay plot-twist...
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
3.0KB

  1. -- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
  2. --
  3. -- GNU General Public Licence (version 3 or later)
  4. with core, ui, effect, attribute, faction;
  5. package body unit is
  6. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  7. view_width : constant integer := 48;
  8. view_height : constant integer := 64;
  9. sprite : array (enumeration) of core.sprite;
  10. icon : array (enumeration) of core.sprite;
  11. view : array (enumeration) of core.sprite;
  12. ------------------------------------------------------------------------------------------
  13. procedure configure is
  14. begin
  15. core.echo (core.comment, "Configuring unit components...");
  16. --
  17. for index in enumeration loop
  18. declare folder : constant string := core.lowercase (faction.enumeration'image (trait (index).kind));
  19. file : constant string := core.lowercase (enumeration'image (index));
  20. begin
  21. sprite (index) := core.import_sprite (core.folder & "/game/unit/" & folder & "/" & file & ".png", 4, 6);
  22. --~icon (index) := core.import_sprite (core.folder & "/icon/unit/" & folder & "/" & file & ".png", 1, 1);
  23. --~view (index) := core.import_sprite (core.folder & "/view/unit/" & folder & "/" & file & ".png", 1, 1);
  24. end;
  25. end loop;
  26. end configure;
  27. ------------------------------------------------------------------------------------------
  28. procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is
  29. begin
  30. core.draw (sprite (index), x, y, state => state);
  31. end draw;
  32. ------------------------------------------------------------------------------------------
  33. procedure draw_icon (index : in enumeration; x, y : in integer) is
  34. begin
  35. ui.draw_overicon (icon (index), trait (index).text, x, y);
  36. end draw_icon;
  37. ------------------------------------------------------------------------------------------
  38. procedure draw_view (index : in enumeration; x, y : in integer) is
  39. offset : constant integer := 4;
  40. begin
  41. core.draw (view (index), x + offset, y + offset);
  42. ui.draw_icon_menu (x, y, view_width + 2 * offset, view_height + 2 * offset);
  43. end draw_view;
  44. ------------------------------------------------------------------------------------------
  45. procedure draw_full (index : in natural; x, y : in integer) is
  46. limit : constant value_limit := value_limit (index);
  47. begin
  48. draw (values (limit).kind, values (limit).state, x, y);
  49. --
  50. for equipment_index in equipment.slot loop
  51. equipment.draw (values (limit).equipments (equipment_index), values (limit).state, x, y);
  52. end loop;
  53. end draw_full;
  54. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  55. end unit;