diff --git a/source/core.adb b/source/core.adb index 12655f8..a3417c2 100644 --- a/source/core.adb +++ b/source/core.adb @@ -4,8 +4,6 @@ with core, ray; -use ray; - package body core is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -14,9 +12,9 @@ package body core is sound_count : integer := 0; font_count : integer := 0; - type texture_data_array is array (natural range <>) of texture; - type sound_data_array is array (natural range <>) of sound; - type font_data_array is array (natural range <>) of font; + type texture_data_array is array (natural range <>) of ray.texture; + type sound_data_array is array (natural range <>) of ray.sound; + type font_data_array is array (natural range <>) of ray.font; texture_array : access texture_data_array; sound_array : access sound_data_array; @@ -107,7 +105,7 @@ package body core is function random_integer (minimum, maximum : in integer) return integer is begin - return get_random (minimum, maximum); + return ray.get_random (minimum, maximum); end random_integer; ------------------------------------------------------------------------------------------ @@ -124,7 +122,7 @@ package body core is function import_sprite (file_path : in string; frames, states : in integer) return sprite is this : sprite; begin - texture_array (texture_count) := load_texture (c_string (file_path)); + texture_array (texture_count) := ray.load_texture (c_string (file_path)); -- texture_count := texture_count + 1; this.index := texture_count - 1; @@ -144,7 +142,7 @@ package body core is function import_song (file_path : in string) return integer is begin - sound_array (sound_count) := load_sound (c_string (file_path)); + sound_array (sound_count) := ray.load_sound (c_string (file_path)); -- sound_count := sound_count + 1; -- @@ -156,7 +154,7 @@ package body core is function import_glyphs (file_path : in string; size, pad : in integer) return glyphs is this : glyphs; begin - font_array (font_count) := load_font (c_string (file_path)); + font_array (font_count) := ray.load_font (c_string (file_path)); -- font_count := font_count + 1; this.index := font_count - 1; @@ -405,89 +403,89 @@ package body core is --~uv => (float (u), float (v), float (width), float (height)), --~view => (float (x), float (y)), --~tint => (255, 255, 255, 255)); - megadraw (data => texture_array (sprite), - uv => (float (u), float (v), float (width), float (height)), - view => (float (x), float (y), float (width) * zoom, float (height) * zoom), - origin => (0.0, 0.0), - rotate => 0.0, - tint => (255, 255, 255, 255)); + ray.megadraw (data => texture_array (sprite), + uv => (float (u), float (v), float (width), float (height)), + view => (float (x), float (y), float (width) * zoom, float (height) * zoom), + origin => (0.0, 0.0), + rotate => 0.0, + tint => (255, 255, 255, 255)); end render_sprite; ------------------------------------------------------------------------------------------ procedure render_string (text : in string; x, y : in integer; colour : in colour_range; index, size, pad : in integer) is begin - draw_text (data => font_array (index), - text => c_string (text), - view => (float ((32 - size) / 2 + x), float ((32 - size) / 2 + y)), - size => float (size), - pad => float (pad), - tint => (255, 255, 255, 255)); + ray.draw_text (data => font_array (index), + text => c_string (text), + view => (float ((32 - size) / 2 + x), float ((32 - size) / 2 + y)), + size => float (size), + pad => float (pad), + tint => (255, 255, 255, 255)); end render_string; ------------------------------------------------------------------------------------------ procedure render_vector (x1, y1, x2, y2 : in integer) is begin - draw_line (x1, y1, x2, y2, (0, 0, 0, 255)); + ray.draw_line (x1, y1, x2, y2, (0, 0, 0, 255)); end render_vector; - function window_width return integer is begin return get_screen_width; end window_width; - function window_height return integer is begin return get_screen_height; end window_height; + function window_width return integer is begin return ray.get_screen_width; end window_width; + function window_height return integer is begin return ray.get_screen_height; end window_height; ------------------------------------------------------------------------------------------ procedure initialize is begin - core.echo (core.comment, "Initializing core components..."); + echo (comment, "Initializing core components..."); -- engine_active := true; texture_array := new texture_data_array (0 .. 1600); sound_array := new sound_data_array (0 .. 4); font_array := new font_data_array (0 .. 4); -- - core.echo (core.ray_ada, "-- Setting trace log level to none (ignoring all default Raylib logs)."); - set_trace_log_level (log_none); - core.echo (core.ray_ada, "-- Initializing Raylib window data..."); - core.echo (core.ray_ada, "-- -- Window title : Chads of Might & Magic"); - core.echo (core.ray_ada, "-- -- Window width : 1800"); - core.echo (core.ray_ada, "-- -- Window height : 900"); - open_window (1800, 900, "Chads of Might & Magic"); - core.echo (core.ray_ada, "-- Initializing Raylib audio device data..."); - open_audio_device; + echo (ray_ada, "-- Setting trace log level to none (ignoring all default Raylib logs)."); + ray.set_trace_log_level (ray.log_none); + echo (ray_ada, "-- Initializing Raylib window data..."); + echo (ray_ada, "-- -- Window title : Chads of Might & Magic"); + echo (ray_ada, "-- -- Window width : 1800"); + echo (ray_ada, "-- -- Window height : 900"); + ray.open_window (1800, 900, "Chads of Might & Magic"); + echo (ray_ada, "-- Initializing Raylib audio device data..."); + ray.open_audio_device; -- - randomization (25071997); - set_target_fps (60); + ray.randomization (25071997); + ray.set_target_fps (60); -- hexagon_grid_sprite := import_sprite ("./sprite/ui/hexagon_grid_tile.png", 1, 1); hexagon_fill_sprite := import_sprite ("./sprite/ui/hexagon_fill_tile.png", 1, 1); -- - core.echo (core.success, "Initialized core components."); + echo (success, "Initialized core components."); end initialize; ------------------------------------------------------------------------------------------ procedure deinitialize is begin - core.echo (core.comment, "Deinitializing core components..."); + echo (comment, "Deinitializing core components..."); -- engine_active := false; -- - core.echo (core.deport, "-- -- Unloading Raylib" & texture_count'image & " textures."); - core.echo (core.deport, "-- -- Unloading Raylib" & sound_count'image & " sounds."); - core.echo (core.deport, "-- -- Unloading Raylib" & font_count'image & " fonts."); + echo (deport, "-- -- Unloading Raylib" & texture_count'image & " textures."); + echo (deport, "-- -- Unloading Raylib" & sound_count'image & " sounds."); + echo (deport, "-- -- Unloading Raylib" & font_count'image & " fonts."); -- - for index in 0 .. texture_count - 1 loop unload_texture (texture_array (index)); end loop; - for index in 0 .. sound_count - 1 loop unload_sound (sound_array (index)); end loop; - for index in 0 .. font_count - 1 loop unload_font (font_array (index)); end loop; + for index in 0 .. texture_count - 1 loop ray.unload_texture (texture_array (index)); end loop; + for index in 0 .. sound_count - 1 loop ray.unload_sound (sound_array (index)); end loop; + for index in 0 .. font_count - 1 loop ray.unload_font (font_array (index)); end loop; -- - core.echo (core.ray_ada, "-- Deinitializing Raylib audio device data..."); - close_audio_device; + echo (ray_ada, "-- Deinitializing Raylib audio device data..."); + ray.close_audio_device; -- - core.echo (core.ray_ada, "-- Deinitializing Raylib window data..."); - close_window; + echo (ray_ada, "-- Deinitializing Raylib window data..."); + ray.close_window; -- - core.echo (core.success, "Deinitialized core components."); + echo (success, "Deinitialized core components."); end deinitialize; ------------------------------------------------------------------------------------------ @@ -499,23 +497,23 @@ package body core is global_time := global_time mod (gameplay_framerate * animation_framerate); gameplay_time := global_time mod (gameplay_framerate); animation_time := global_time / (gameplay_framerate / animation_framerate); - framerate := integer (get_fps); - signal := get_key_pressed; - cursor.x := get_mouse_x; - cursor.y := get_mouse_y; + framerate := integer (ray.get_fps); + signal := ray.get_key_pressed; + cursor.x := ray.get_mouse_x; + cursor.y := ray.get_mouse_y; -- - end_drawing; + ray.end_drawing; -- - if exit_key_is_pressed then + if ray.exit_key_is_pressed then engine_active := false; end if; -- - if mouse_button_is_pressed (mouse_button_left) then cursor_mode := 1; end if; - if mouse_button_is_pressed (mouse_button_right) then cursor_mode := 2; end if; - if mouse_button_is_pressed (mouse_button_middle) then cursor_mode := 3; end if; - if mouse_button_is_released (mouse_button_left) then cursor_mode := 0; end if; - if mouse_button_is_released (mouse_button_right) then cursor_mode := 0; end if; - if mouse_button_is_released (mouse_button_middle) then cursor_mode := 0; end if; + if ray.mouse_button_is_pressed (ray.mouse_button_left) then cursor_mode := 1; end if; + if ray.mouse_button_is_pressed (ray.mouse_button_right) then cursor_mode := 2; end if; + if ray.mouse_button_is_pressed (ray.mouse_button_middle) then cursor_mode := 3; end if; + if ray.mouse_button_is_released (ray.mouse_button_left) then cursor_mode := 0; end if; + if ray.mouse_button_is_released (ray.mouse_button_right) then cursor_mode := 0; end if; + if ray.mouse_button_is_released (ray.mouse_button_middle) then cursor_mode := 0; end if; -- case signal is when 48 .. 57 => signal_mode := signal - 48 + signal_code'pos (signal_0); @@ -540,21 +538,21 @@ package body core is when others => signal_mode := signal_code'pos (signal_none); end case; -- - begin_drawing; + ray.begin_drawing; -- - clear_background ((50, 60, 70, 255)); + ray.clear_background ((50, 60, 70, 255)); end synchronize; ------------------------------------------------------------------------------------------ - procedure play_song (index : in integer) is begin play_sound (sound_array (index)); end play_song; - procedure stop_song (index : in integer) is begin stop_sound (sound_array (index)); end stop_song; + procedure play_song (index : in integer) is begin ray.play_sound (sound_array (index)); end play_song; + procedure stop_song (index : in integer) is begin ray.stop_sound (sound_array (index)); end stop_song; ------------------------------------------------------------------------------------------ procedure overlay is begin - draw_rectangle (0, 0, window_width, window_height, (0, 0, 0, 100)); + ray.draw_rectangle (0, 0, window_width, window_height, (0, 0, 0, 100)); end overlay; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------