Prototype game engine for Heroes of Might & Magic, featuring a gameplay plot-twist...
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

197 rindas
7.8KB

  1. -- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
  2. --
  3. -- GNU General Public Licence (version 3 or later)
  4. with ada.text_io, ada.strings.unbounded, interfaces.c, ray;
  5. use ada.text_io, ada.strings.unbounded, interfaces.c, ray;
  6. package core is
  7. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. type echo_status is (
  9. failure, warning, success, comment, import, export
  10. );
  11. type cursor_code is (
  12. cursor_none, cursor_left, cursor_right, cursor_middle
  13. );
  14. type signal_code is (
  15. signal_none, signal_space, signal_0, signal_1, signal_2, signal_3,
  16. signal_4, signal_5, signal_6, signal_7, signal_8, signal_9,
  17. signal_a, signal_b, signal_c, signal_d, signal_e, signal_f,
  18. signal_g, signal_h, signal_i, signal_j, signal_k, signal_l,
  19. signal_m, signal_n, signal_o, signal_p, signal_q, signal_r,
  20. signal_s, signal_t, signal_u, signal_v, signal_w, signal_x,
  21. signal_y, signal_z, signal_grave, signal_escape, signal_enter, signal_tab,
  22. signal_backspace, signal_right, signal_left, signal_down, signal_up, signal_kp_0,
  23. signal_kp_1, signal_kp_2, signal_kp_3, signal_kp_4, signal_kp_5, signal_kp_6,
  24. signal_kp_7, signal_kp_8, signal_kp_9, signal_kp_subtract, signal_kp_add, signal_left_shift,
  25. signal_left_control
  26. );
  27. type animation is (
  28. idle, walk, melee, shoot, wounded, dead
  29. );
  30. ------------------------------------------------------------------------------------------
  31. type colour_range is range 0 .. 2 ** 8 - 1;
  32. for colour_range'size use 8;
  33. type colour is record r, g, b, a : colour_range; end record;
  34. subtype short_string is string (1 .. 24);
  35. subtype long_string is string (1 .. 72);
  36. type pointer is access procedure;
  37. type vector is record x, y : integer; end record;
  38. type sprite is record index, width, height, frames, states : integer; end record;
  39. type font is record index, scale, space : integer; end record;
  40. type song is record index : integer; end record;
  41. type point is record
  42. value, limit : natural;
  43. end record;
  44. type string_box_data is record
  45. data : access string := null;
  46. text : unbounded_string := null_unbounded_string;
  47. size : vector := (0, 0);
  48. end record;
  49. ------------------------------------------------------------------------------------------
  50. folder : constant string := ".";
  51. icon : constant natural := 32;
  52. base : constant natural := 16;
  53. gameplay_framerate : constant natural := 60;
  54. animation_framerate : constant natural := 4;
  55. echo_mark : constant array (echo_status) of boolean := (
  56. failure => true,
  57. warning => true,
  58. success => true,
  59. comment => true,
  60. import => true,
  61. export => true
  62. );
  63. engine_active : boolean := false;
  64. cursor : vector := (0, 0);
  65. camera : vector := (0, 0);
  66. cursor_mode : cursor_code := cursor_none;
  67. signal_mode : signal_code := signal_none;
  68. framerate : integer := 0;
  69. global_time : natural := 0;
  70. gameplay_time : natural := 0;
  71. animation_time : natural := 0;
  72. wheel : float := 0.0;
  73. zoom : natural := 1;
  74. help_box : string_box_data;
  75. text_box : string_box_data;
  76. global_mapshot : ray.image;
  77. ------------------------------------------------------------------------------------------
  78. function "=" (a, b : in signal_code) return boolean;
  79. function "=" (a, b : in cursor_code) return boolean;
  80. function "/" (a, b : in signal_code) return boolean;
  81. function "/" (a, b : in cursor_code) return boolean;
  82. function "+" (data : in point; modifier : in natural) return point;
  83. function "-" (data : in point; modifier : in natural) return point;
  84. function "*" (data : in point; modifier : in natural) return point;
  85. function "/" (data : in point; modifier : in natural) return point;
  86. procedure echo ( status : in echo_status; text : in string);
  87. procedure echo_when (condition : in boolean; status : in echo_status; text : in string);
  88. procedure dash;
  89. procedure semi_dash;
  90. function c_string (ada_string : in string) return string;
  91. function random (minimum, maximum : in integer) return integer;
  92. function clip (value, minimum, maximum : in integer) return integer;
  93. function lowercase (text : in string) return string;
  94. function window_width return integer;
  95. function window_height return integer;
  96. function center_x (object : in integer) return integer;
  97. function center_y (object : in integer) return integer;
  98. function cursor_inside (x, y, width, height : in integer) return boolean;
  99. function import_sprite (file_path : in string; frames, states : in integer) return sprite;
  100. function import_font (file_path : in string; scale, space : in integer) return font;
  101. function import_song (file_path : in string) return song;
  102. procedure import_text (data : in out string_box_data; file_path : in string);
  103. procedure create_image (width, height : in integer);
  104. procedure render_image (data : in sprite; x, y, u, v, width, height : in integer);
  105. procedure export_image (file_path : in string);
  106. procedure draw (data : in sprite := (others => 0);
  107. x : in integer := 0;
  108. y : in integer := 0;
  109. u : in integer := 0;
  110. v : in integer := 0;
  111. width : in integer := 0;
  112. height : in integer := 0;
  113. state : in animation := idle;
  114. factor : in integer := zoom;
  115. tint : in colour := (others => 255));
  116. procedure draw_horizontally (data : in sprite; x, y, width, factor : in integer; tint : in colour := (others => 255));
  117. procedure draw_vertically (data : in sprite; x, y, height, factor : in integer; tint : in colour := (others => 255));
  118. procedure write (text : in string := "";
  119. x : in integer := 0;
  120. y : in integer := 0;
  121. tint : in colour := (others => 255);
  122. size : in integer := 0;
  123. data : in font := (others => 0));
  124. procedure play (index : in integer);
  125. procedure stop (index : in integer);
  126. procedure overlay;
  127. function read_help_box return string;
  128. function read_text_box return string;
  129. procedure write_help_box (text : in string);
  130. procedure write_text_box (text : in string);
  131. procedure increment (value : in out integer);
  132. procedure decrement (value : in out integer);
  133. procedure idle_skip;
  134. procedure move_camera_up;
  135. procedure move_camera_down;
  136. procedure move_camera_left;
  137. procedure move_camera_right;
  138. procedure toggle_fullscreen;
  139. procedure initialize;
  140. procedure deinitialize;
  141. procedure synchronize;
  142. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  143. end core;