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.

206 lines
13KB

  1. -- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
  2. --
  3. -- GNU General Public Licence (version 3 or later)
  4. with interfaces.c, system;
  5. use interfaces.c, system;
  6. package ray is
  7. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. type pointer is access all system.address;
  9. type colour_range is range 0 .. 2 ** 8 - 1;
  10. type logical is new boolean;
  11. for logical'size use 32;
  12. for colour_range'size use 8;
  13. type pixels is array (natural range <>) of colour_range;
  14. type window_flag is (
  15. flag_none,
  16. flag_fullscreen_mode,
  17. flag_window_resizable,
  18. flag_window_undecorated,
  19. flag_window_transparent,
  20. flag_msaa_x4_hint,
  21. flag_vsync_hint,
  22. flag_window_hidden,
  23. flag_window_always_run,
  24. flag_window_minimized,
  25. flag_window_maximized,
  26. flag_window_unfocused,
  27. flag_window_topmost,
  28. flag_window_high_dpi,
  29. flag_window_mouse_passthrough,
  30. flag_borderless_windowed_mode,
  31. flag_interlaced_hint
  32. ) with convention => c;
  33. for window_flag use (
  34. flag_none => 16#00000000#, -- 0
  35. flag_fullscreen_mode => 16#00000002#, -- 2
  36. flag_window_resizable => 16#00000004#, -- 4
  37. flag_window_undecorated => 16#00000008#, -- 8
  38. flag_window_transparent => 16#00000010#, -- 16
  39. flag_msaa_x4_hint => 16#00000020#, -- 32
  40. flag_vsync_hint => 16#00000040#, -- 64
  41. flag_window_hidden => 16#00000080#, -- 128
  42. flag_window_always_run => 16#00000100#, -- 256
  43. flag_window_minimized => 16#00000200#, -- 512
  44. flag_window_maximized => 16#00000400#, -- 1024
  45. flag_window_unfocused => 16#00000800#, -- 2048
  46. flag_window_topmost => 16#00001000#, -- 4096
  47. flag_window_high_dpi => 16#00002000#, -- 8192
  48. flag_window_mouse_passthrough => 16#00004000#, -- 16384
  49. flag_borderless_windowed_mode => 16#00008000#, -- 32768
  50. flag_interlaced_hint => 16#00010000# -- 65536
  51. );
  52. type trace_log_level is (
  53. log_all, log_trace, log_debug, log_info, log_warning, log_error,
  54. log_fatal, log_none
  55. ) with convention => c;
  56. type mouse_button is (
  57. mouse_button_left, mouse_button_right, mouse_button_middle, mouse_button_side, mouse_button_extra, mouse_button_forward,
  58. mouse_button_back
  59. ) with convention => c;
  60. type vector is record x, y : float; end record with convention => c_pass_by_copy;
  61. type colour is record r, g, b, a : colour_range; end record with convention => c_pass_by_copy;
  62. type rectangle is record x ,y, width, height : float; end record with convention => c_pass_by_copy;
  63. type texture is record id : natural; width, height, mipmaps, format : integer; end record with convention => c_pass_by_copy;
  64. type image is record data : access pixels; width, height, mipmaps : integer; format : integer := 7; end record with convention => c_pass_by_copy;
  65. type font is record base, count, pad : integer; data : texture; squares : pointer; glyphs : pointer; end record with convention => c_pass_by_copy;
  66. type stream is record buffer, processor : pointer; rate, size, channels : natural; end record with convention => c_pass_by_copy;
  67. type sound is record data : stream; frame : natural; end record with convention => c_pass_by_copy;
  68. no_texture : texture;
  69. no_font : font;
  70. no_sound : sound;
  71. procedure set_window_flags (flags : window_flag := flag_none) with import => true, convention => c, external_name => "SetConfigFlags";
  72. procedure open_window (width, height : in integer; title : in string) with import => true, convention => c, external_name => "InitWindow";
  73. procedure close_window with import => true, convention => c, external_name => "CloseWindow";
  74. procedure open_audio_device with import => true, convention => c, external_name => "InitAudioDevice";
  75. procedure close_audio_device with import => true, convention => c, external_name => "CloseAudioDevice";
  76. procedure set_exit_key (key : in integer) with import => true, convention => c, external_name => "SetExitKey";
  77. function exit_key_is_pressed return logical with import => true, convention => c, external_name => "WindowShouldClose";
  78. function get_key_pressed return integer with import => true, convention => c, external_name => "GetKeyPressed";
  79. function mouse_button_is_pressed (button : in mouse_button) return logical with import => true, convention => c, external_name => "IsMouseButtonPressed";
  80. function mouse_button_is_released (button : in mouse_button) return logical with import => true, convention => c, external_name => "IsMouseButtonReleased";
  81. function get_mouse_x return integer with import => true, convention => c, external_name => "GetMouseX";
  82. function get_mouse_y return integer with import => true, convention => c, external_name => "GetMouseY";
  83. function get_mouse_vector return vector with import => true, convention => c, external_name => "GetMousePosition";
  84. function get_screen_width return integer with import => true, convention => c, external_name => "GetScreenWidth";
  85. function get_screen_height return integer with import => true, convention => c, external_name => "GetScreenHeight";
  86. procedure clear_background (tint : in colour) with import => true, convention => c, external_name => "ClearBackground";
  87. procedure begin_drawing with import => true, convention => c, external_name => "BeginDrawing";
  88. procedure end_drawing with import => true, convention => c, external_name => "EndDrawing";
  89. procedure set_target_fps (fps : in integer) with import => true, convention => c, external_name => "SetTargetFPS";
  90. function get_fps return integer with import => true, convention => c, external_name => "GetFPS";
  91. procedure draw_fps (x, y : in integer) with import => true, convention => c, external_name => "DrawFPS";
  92. procedure randomization (seed : in natural) with import => true, convention => c, external_name => "SetRandomSeed";
  93. function get_random (minimum, maximum : in integer) return integer with import => true, convention => c, external_name => "GetRandomValue";
  94. procedure take_screenshot (file_path : in string := "screenshot.png") with import => true, convention => c, external_name => "TakeScreenshot";
  95. procedure set_trace_log_level (level : in trace_log_level) with import => true, convention => c, external_name => "SetTraceLogLevel";
  96. function load_texture (file_path : in string) return texture with import => true, convention => c, external_name => "LoadTexture";
  97. function load_sound (file_path : in string) return sound with import => true, convention => c, external_name => "LoadSound";
  98. function load_font (file_path : in string) return font with import => true, convention => c, external_name => "LoadFont";
  99. function load_image (file_path : in string) return image with import => true, convention => c, external_name => "LoadImage";
  100. procedure unload_texture (data : in texture) with import => true, convention => c, external_name => "UnloadTexture";
  101. procedure unload_sound (data : in sound) with import => true, convention => c, external_name => "UnloadSound";
  102. procedure unload_font (data : in font) with import => true, convention => c, external_name => "UnloadFont";
  103. procedure unload_image (data : in image) with import => true, convention => c, external_name => "UnloadImage";
  104. function image_colour (width, height : in integer; tint : in colour) return image with import => true, convention => c, external_name => "GenImageColor";
  105. function image_import (data : in texture) return image with import => true, convention => c, external_name => "LoadImageFromTexture";
  106. procedure image_delete (data : in image) with import => true, convention => c, external_name => "UnloadImage";
  107. function image_export (data : in image; file_path : in string) return integer with import => true, convention => c, external_name => "ExportImage";
  108. procedure image_render (data : in out image;
  109. copy : in image;
  110. from : in rectangle := (others => 0.0);
  111. to : in rectangle := (others => 0.0);
  112. tint : in colour := (others => 255)
  113. ) with import => true, convention => c, external_name => "ImageDraw";
  114. procedure draw_line (x0, y0, x1, y1 : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawLine";
  115. procedure draw_rectangle (x, y, width, height : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawRectangle";
  116. procedure draw_text (
  117. data : in font := no_font;
  118. text : in string := "--";
  119. view : in vector := (0.0, 0.0);
  120. origin : in vector := (0.0, 0.0);
  121. rotate : in float := 0.0;
  122. scale : in float := 0.0;
  123. space : in float := 0.0;
  124. tint : in colour := (others => 255)
  125. ) with import => true, convention => c, external_name => "DrawTextPro";
  126. procedure draw_texture (
  127. data : in texture := no_texture;
  128. uv : in rectangle := (others => 0.0);
  129. view : in rectangle := (others => 0.0);
  130. origin : in vector := (0.0, 0.0);
  131. rotate : in float := 0.0;
  132. tint : in colour := (others => 255)
  133. ) with import => true, convention => c, external_name => "DrawTexturePro";
  134. procedure play_sound (data : in sound) with import => true, convention => c, external_name => "PlaySound";
  135. procedure stop_sound (data : in sound) with import => true, convention => c, external_name => "StopSound";
  136. procedure pause_sound (data : in sound) with import => true, convention => c, external_name => "PauseSound";
  137. procedure resume_sound (data : in sound) with import => true, convention => c, external_name => "ResumeSound";
  138. procedure toggle_fullscreen with import => true, convention => c, external_name => "ToggleFullscreen";
  139. procedure window_icon (icon : in image) with import => true, convention => c, external_name => "SetWindowIcon";
  140. --~void SetWindowMinSize(int width, int height);
  141. --~void SetWindowMaxSize(int width, int height);
  142. --~void SetWindowSize(int width, int height);
  143. --~void ShowCursor(void);
  144. --~void HideCursor(void);
  145. --~double GetTime(void);
  146. --~void OpenURL(const char *url);
  147. function load_text (file : in string) return char_array with import => true, convention => c, external_name => "LoadFileText";
  148. function mouse_wheel_move return float with import => true, convention => c, external_name => "GetMouseWheelMove";
  149. --~procedure unload_file (data : in access string) with import => true, convention => c, external_name => "UnloadFileText";
  150. --~bool SaveFileText(const char *fileName, char *text);
  151. --~FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs);
  152. --~void UnloadDirectoryFiles(FilePathList files);
  153. --~unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize);
  154. --~unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize);
  155. --~void ImageDrawPixel(Image *dst, int posX, int posY, Color color);
  156. --~void SetTextLineSpacing(int spacing);
  157. --~Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing);
  158. --~bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);
  159. --~void SetMasterVolume(float volume);
  160. --~Music LoadMusicStream(const char *fileName);
  161. --~void UnloadMusicStream(Music music);
  162. --~void PlayMusicStream(Music music);
  163. --~void PauseMusicStream(Music music);
  164. --~void ResumeMusicStream(Music music);
  165. --~void SetMusicVolume(Music music, float volume);
  166. --~float GetMusicTimeLength(Music music);
  167. --~RLAPI float GetMusicTimePlayed(Music music);
  168. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  169. end ray;