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.

60 lines
2.4KB

  1. -- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
  2. --
  3. -- GNU General Public Licence (version 3 or later)
  4. with core, ui, effect;
  5. package body magic is
  6. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  7. view_width : constant natural := 64;
  8. view_height : constant natural := 64;
  9. view : array (enumeration) of core.sprite;
  10. ------------------------------------------------------------------------------------------
  11. procedure configure is
  12. begin
  13. core.echo (core.comment, "Configuring magic components...");
  14. --
  15. for index in enumeration loop
  16. declare folder : constant string := core.lowercase (school'image (trait (index).kind));
  17. file : constant string := core.lowercase (enumeration'image (index));
  18. begin
  19. view (index) := core.import_sprite (core.folder & "/view/magic/" & folder & "/" & file & ".png", 1, 1);
  20. end;
  21. end loop;
  22. end configure;
  23. ------------------------------------------------------------------------------------------
  24. procedure draw (index : in enumeration; x, y : in integer) is
  25. begin
  26. ui.draw_sprite (view (index), trait (index).text, x, y, 0);
  27. end draw;
  28. ------------------------------------------------------------------------------------------
  29. procedure menu (x, y : in integer; center : in boolean) is
  30. offset : constant integer := core.icon;
  31. width : constant integer := count * view_width + (count + 1) * offset + offset / 2;
  32. height : constant integer := view_height + 2 * offset + offset / 2;
  33. move_x : constant integer := (if center then (core.window_width - width) / 2 else x);
  34. move_y : constant integer := (if center then (core.window_height - height) / 2 else y);
  35. begin
  36. ui.draw_tiny_menu (x => move_x,
  37. y => move_y,
  38. width => width,
  39. height => height);
  40. --
  41. for index in enumeration loop
  42. draw (index, move_x + offset + enumeration'pos (index) * (offset + view_width), move_y + offset);
  43. end loop;
  44. end menu;
  45. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  46. end magic;