Prototype game engine for Heroes of Might & Magic, featuring a gameplay plot-twist...
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

133 строки
5.6KB

  1. -- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
  2. --
  3. -- GNU General Public Licence (version 3 or later)
  4. with core, ui, attribute, skill, resource, faction, equipment;
  5. package body chad is
  6. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  7. view_width : constant integer := 64;
  8. view_height : constant integer := 96;
  9. sprite : array (enumeration) of core.sprite;
  10. view : array (enumeration) of core.sprite;
  11. pepe_the_frog : core.sprite;
  12. alice_the_mad : core.sprite;
  13. ------------------------------------------------------------------------------------------
  14. procedure configure is
  15. begin
  16. core.echo (core.comment, "Configuring chad components...");
  17. --
  18. pepe_the_frog := core.import_sprite (core.folder & "/game/unit/pepe_the_frog.png", 4, 6);
  19. alice_the_mad := core.import_sprite (core.folder & "/game/unit/alice_the_mad.png", 4, 6);
  20. --
  21. for index in enumeration loop
  22. sprite (index) := core.import_sprite (core.folder & "/game/chad/" & core.lowercase (enumeration'image (index)) & ".png", 4, 6);
  23. view (index) := core.import_sprite (core.folder & "/view/chad/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);
  24. null;
  25. end loop;
  26. end configure;
  27. ------------------------------------------------------------------------------------------
  28. procedure draw (player : in value; x, y : in integer) is
  29. begin
  30. core.draw (sprite (player.index), x, y, state => player.state);
  31. --
  32. for index in equipment.slot loop
  33. equipment.draw (player.equipments (index), player.state, x, y);
  34. end loop;
  35. end draw;
  36. ------------------------------------------------------------------------------------------
  37. procedure draw_data (player : in value; x, y : in integer) is
  38. offset : constant integer := 8;
  39. begin
  40. ui.draw_frame ("--", x, y, 360 + 2 * offset, 96 + 2 * offset);
  41. --
  42. ui.draw_sprite (view (player.index), trait (player.index).name, x + offset, y + offset, 0);
  43. --
  44. ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 1 * core.icon + offset, 4 * core.icon, float (player.health.value) / float (player.health.limit), (255, 0, 0, 255));
  45. ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 2 * core.icon + offset, 4 * core.icon, float (player.mana.value) / float (player.mana.limit), (0, 0, 255, 255));
  46. ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 3 * core.icon + offset, 4 * core.icon, float (player.stamina.value) / float (player.stamina.limit), (0, 255, 0, 255));
  47. --
  48. ui.write (text => "Health " & player.health.value'image & " /" & player.health.limit'image,
  49. x => x + view_width + 4 * core.icon + 3 * offset,
  50. y => y + 2 * offset,
  51. tint => (255, 127, 127, 255),
  52. size => 15,
  53. code => true);
  54. ui.write (text => "Mana " & player.mana.value'image & " /" & player.mana.limit'image,
  55. x => x + view_width + 4 * core.icon + 3 * offset,
  56. y => y + core.icon + 2 * offset,
  57. tint => (127, 127, 255, 255),
  58. size => 15,
  59. code => true);
  60. ui.write (text => "Stamina" & player.stamina.value'image & " /" & player.stamina.limit'image,
  61. x => x + view_width + 4 * core.icon + 3 * offset,
  62. y => y + 2 * core.icon + 2 * offset,
  63. tint => (127, 255, 127, 255),
  64. size => 15,
  65. code => true);
  66. --
  67. attribute.draw_points (player.attributes, x, y + 96 + 3 * offset);
  68. --
  69. for index_y in 0 .. 3 loop
  70. for index_x in 0 .. 5 loop
  71. ui.draw_icon (data => equipment.icon (player.items (6 * index_y + index_x)),
  72. text => equipment.trait (player.items (6 * index_y + index_x)).name,
  73. x => x + index_x * core.icon,
  74. y => y + 96 + 4 * offset + 2 * core.icon + index_y * core.icon);
  75. end loop;
  76. end loop;
  77. --
  78. skill.draw_points (player.skills, x, y + 96 + 5 * offset + 6 * core.icon);
  79. end draw_data;
  80. ------------------------------------------------------------------------------------------
  81. procedure draw_menu (player : in value; x, y : in integer) is
  82. begin
  83. null;
  84. end draw_menu;
  85. ------------------------------------------------------------------------------------------
  86. function take_equipment_item (player : in out value; item : in equipment.enumeration) return boolean is
  87. use type equipment.enumeration;
  88. begin
  89. if player.item_count = item_limit or item = equipment.none then
  90. return false;
  91. end if;
  92. --
  93. player.items (player.item_count) := item;
  94. --
  95. core.increment (player.item_count);
  96. --
  97. return true;
  98. end take_equipment_item;
  99. ------------------------------------------------------------------------------------------
  100. procedure draw_pepe is
  101. begin
  102. core.draw (pepe_the_frog, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
  103. end draw_pepe;
  104. ------------------------------------------------------------------------------------------
  105. procedure draw_alice is
  106. begin
  107. core.draw (alice_the_mad, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
  108. end draw_alice;
  109. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  110. end chad;