Prototype game engine for Heroes of Might & Magic, featuring a gameplay plot-twist...
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

175 行
6.2KB

  1. -- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
  2. --
  3. -- GNU General Public Licence (version 3 or later)
  4. pragma ada_2012;
  5. with core, ui, effect, attribute, skill, resource, faction, might, magic, item, unit, construction, chad, world, ai;
  6. procedure main is
  7. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. side_panel : integer := 480;
  9. preview_x : integer := 64;
  10. preview_y : integer := 64;
  11. preview_width : integer := 0;
  12. preview_height : integer := 0;
  13. text_box_height : integer := 32;
  14. player : chad.information := chad.trait (chad.ognjen);
  15. ------------------------------------------------------------------------------------------
  16. type menu_index is (
  17. menu_none, menu_attribute, menu_skill, menu_resource, menu_unit, menu_might, menu_magic
  18. );
  19. menu_limit : constant integer := 3;
  20. menu_count : integer := 0;
  21. menu_stack : array (1 .. menu_limit) of menu_index := (others => menu_none);
  22. procedure menu_insert (index : in menu_index) is
  23. begin
  24. if menu_count = menu_limit then return; end if;
  25. --
  26. menu_count := menu_count mod menu_limit + 1;
  27. --
  28. menu_stack (menu_count) := index;
  29. end menu_insert;
  30. procedure menu_remove is
  31. begin
  32. if menu_count = 0 then return; end if;
  33. --
  34. menu_stack (menu_count) := menu_none;
  35. --
  36. menu_count := menu_count - 1;
  37. end menu_remove;
  38. procedure menu_render is
  39. begin
  40. if menu_count > 0 then
  41. core.overlay;
  42. end if;
  43. --
  44. for index in 1 .. menu_limit
  45. loop
  46. case menu_stack (index) is
  47. when menu_none => null;
  48. when menu_attribute => attribute.menu (100, 100, false);
  49. when menu_skill => skill.menu (200, 200, false);
  50. when menu_resource => resource.menu (300, 300, false);
  51. when menu_unit => unit.menu (0, 0, true);
  52. when menu_might => might.menu (0, 0, true);
  53. when menu_magic => magic.menu (0, 0, true);
  54. end case;
  55. end loop;
  56. end menu_render;
  57. ------------------------------------------------------------------------------------------
  58. procedure idle is begin null; end idle;
  59. procedure move_camera_up is begin core.camera.y := core.camera.y - 1; end move_camera_up;
  60. procedure move_camera_down is begin core.camera.y := core.camera.y + 1; end move_camera_down;
  61. procedure move_camera_left is begin core.camera.x := core.camera.x - 1; end move_camera_left;
  62. procedure move_camera_right is begin core.camera.x := core.camera.x + 1; end move_camera_right;
  63. procedure show_attribute_menu is begin menu_insert (menu_attribute); end show_attribute_menu;
  64. procedure show_skill_menu is begin menu_insert (menu_skill); end show_skill_menu;
  65. procedure show_resource_menu is begin menu_insert (menu_resource); end show_resource_menu;
  66. procedure show_unit_menu is begin menu_insert (menu_unit); end show_unit_menu;
  67. procedure show_might_menu is begin menu_insert (menu_might); end show_might_menu;
  68. procedure show_magic_menu is begin menu_insert (menu_magic); end show_magic_menu;
  69. procedure hide_top_menu is begin menu_remove; end hide_top_menu;
  70. signal_list : constant array (core.signal_code) of access procedure := (
  71. core.signal_up => move_camera_up'access,
  72. core.signal_down => move_camera_down'access,
  73. core.signal_left => move_camera_left'access,
  74. core.signal_right => move_camera_right'access,
  75. core.signal_a => show_attribute_menu'access,
  76. core.signal_s => show_skill_menu'access,
  77. core.signal_r => show_resource_menu'access,
  78. core.signal_u => show_unit_menu'access,
  79. core.signal_m => show_might_menu'access,
  80. core.signal_n => show_magic_menu'access,
  81. core.signal_grave => hide_top_menu'access,
  82. others => idle'access
  83. );
  84. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  85. begin
  86. core.dash;
  87. core.echo (core.comment, "Copyright (C) 2024 -- Ognjen 'xolatile' Milan Robovic");
  88. core.echo (core.comment, "Version -- 1.0.0");
  89. core.echo (core.comment, "License -- GNU/GPLv3+");
  90. core.echo (core.comment, "Xhads is free software, you can redistribute it and modify it under the terms of the GNU General Public License by Free Software Foundation.");
  91. core.dash;
  92. core.initialize;
  93. ui.configure;
  94. core.play (core.import_song (core.c_string ("./song/main_menu.ogg")).index);
  95. attribute.configure;
  96. skill.configure;
  97. resource.configure;
  98. --~might.configure;
  99. --~magic.configure;
  100. item.configure;
  101. unit.configure;
  102. construction.configure;
  103. chad.configure;
  104. world.configure;
  105. ai.configure;
  106. world.make (world.ash, 120, 100);
  107. preview_width := core.window_width - side_panel;
  108. preview_height := core.window_height - text_box_height;
  109. core.dash;
  110. core.echo (core.success, "Successfully initialized game data, entering main gameplay loop.");
  111. core.dash;
  112. ------------------------------------------------------------------------------------------
  113. gameplay: loop
  114. core.synchronize;
  115. --
  116. exit when core.engine_active = false;
  117. --
  118. ui.active := (if core.cursor_mode = 3 then ui.default else ui.steam);
  119. --
  120. core.camera.x := core.clip (core.camera.x, 0, world.width - preview_width / core.base);
  121. core.camera.y := core.clip (core.camera.y, 0, world.height - preview_height / core.base);
  122. --
  123. world.draw;
  124. --
  125. ui.draw_menu (0, 0, preview_width, preview_height, false);
  126. ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height, true);
  127. --
  128. ui.draw_state_box (preview_width + 32, 32);
  129. --
  130. signal_list (core.signal_code'val (core.signal_mode)).all;
  131. --
  132. --~magic.menu (0, 0, true);
  133. --~might.menu (0, 0, true);
  134. --
  135. menu_render;
  136. --
  137. ui.draw_text_box (0, core.window_height - text_box_height, core.window_width, text_box_height);
  138. end loop gameplay;
  139. ------------------------------------------------------------------------------------------
  140. core.deinitialize;
  141. core.dash;
  142. end main;