Finished and debugged Raylib-Ada inclusion...

This commit is contained in:
Ognjen Milan Robovic 2024-03-17 17:52:59 -04:00
parent 86b6cdf8ed
commit f11c15dc02
2 changed files with 34 additions and 29 deletions

View File

@ -8,11 +8,12 @@ package body core is
type colour is range 0 .. 2 ** 32 - 1; type colour is range 0 .. 2 ** 32 - 1;
-- Quick fix... -- Quick fix...
type rectangle is record x, y, width, height : integer; end record; type rectangle is record x, y, width, height : float; end record with convention => c_pass_by_copy;
type fector is record x, y : float; end record with convention => c_pass_by_copy;
-- Fucking abomination... -- Fucking abomination...
type texture_data is record id : natural; width, height, mipmaps, format : integer; end record; type texture_data is record id : natural; width, height, mipmaps, format : integer; end record with convention => c_pass_by_copy;
type sound_data is record buffer, processor : integer; sampleRate, sampleSize, channels, frameCount : natural; end record; type sound_data is record buffer, processor : integer; sampleRate, sampleSize, channels, frameCount : natural; end record with convention => c_pass_by_copy;
type font_data is record baseSize, glyphCount, glyphPadding : integer; id : texture_data; recs, glyphs : integer; end record; type font_data is record baseSize, glyphCount, glyphPadding : integer; id : texture_data; recs, glyphs : integer; end record with convention => c_pass_by_copy;
-- --
procedure initialize_video (width, height : in integer; title : in string) with import => true, convention => c, external_name => "InitWindow"; procedure initialize_video (width, height : in integer; title : in string) with import => true, convention => c, external_name => "InitWindow";
procedure initialize_audio with import => true, convention => c, external_name => "InitAudioDevice"; procedure initialize_audio with import => true, convention => c, external_name => "InitAudioDevice";
@ -22,7 +23,7 @@ package body core is
procedure deinitialize_frame with import => true, convention => c, external_name => "EndDrawing"; procedure deinitialize_frame with import => true, convention => c, external_name => "EndDrawing";
-- --
procedure error_callback (callback : in integer) with import => true, convention => c, external_name => "SetTraceLogLevel"; procedure error_callback (callback : in integer) with import => true, convention => c, external_name => "SetTraceLogLevel";
procedure clear_frame (colour : in integer) with import => true, convention => c, external_name => "ClearBackground"; procedure clear_frame (pallete : in colour) with import => true, convention => c, external_name => "ClearBackground";
procedure limit_framerate (framerate : in integer) with import => true, convention => c, external_name => "SetTargetFPS"; procedure limit_framerate (framerate : in integer) with import => true, convention => c, external_name => "SetTargetFPS";
function queue_framerate return float with import => true, convention => c, external_name => "GetFPS"; function queue_framerate return float with import => true, convention => c, external_name => "GetFPS";
function close_callback return integer with import => true, convention => c, external_name => "WindowShouldClose"; function close_callback return integer with import => true, convention => c, external_name => "WindowShouldClose";
@ -46,8 +47,8 @@ package body core is
procedure play_sound (data : in sound_data) with import => true, convention => c, external_name => "PlaySound"; procedure play_sound (data : in sound_data) with import => true, convention => c, external_name => "PlaySound";
procedure stop_sound (data : in sound_data) with import => true, convention => c, external_name => "StopSound"; procedure stop_sound (data : in sound_data) with import => true, convention => c, external_name => "StopSound";
-- What the fuck... -- What the fuck...
procedure draw_texture (data : in texture_data; s, d : in rectangle; o : in vector; rotation : in float; tint : in colour) with import => true, convention => c, external_name => "DrawTexturePro"; procedure draw_texture (data : in texture_data; s, d : in rectangle; o : in fector; rotation : in float; tint : in colour) with import => true, convention => c, external_name => "DrawTexturePro";
procedure draw_string (data : in font_data; text : in string; p, o : in vector; r, t, s : in float; tint : in colour) with import => true, convention => c, external_name => "DrawTextPro"; procedure draw_string (data : in font_data; text : in string; p, o : in fector; r, t, s : in float; tint : in colour) with import => true, convention => c, external_name => "DrawTextPro";
procedure draw_vector (x1, y1, x2, y2 : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawLine"; procedure draw_vector (x1, y1, x2, y2 : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawLine";
-- Please... -- Please...
function get_random_value (minimum, maximum : in integer) return integer with import => true, convention => c, external_name => "GetRandomValue"; function get_random_value (minimum, maximum : in integer) return integer with import => true, convention => c, external_name => "GetRandomValue";
@ -444,14 +445,15 @@ package body core is
procedure render_sprite (sprite, x, y, u, v, width, height : in integer) is procedure render_sprite (sprite, x, y, u, v, width, height : in integer) is
begin begin
draw_texture (texture_array (sprite), (u, v, width, height), (x, y, abs width, abs height), (0, 0), 0.0, 16#FFFFFFFF#); draw_texture (texture_array (sprite), (float (u), float (v), float (width), float (height)),
(float (x), float (y), float (abs width), float (abs height)), (0.0, 0.0), 0.0, 16#FFFFFFFF#);
end render_sprite; end render_sprite;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure render_string (text : in string; x, y, colour, index, size, pad : in integer) is procedure render_string (text : in string; x, y, colour, index, size, pad : in integer) is
begin begin
draw_string (font_array (index), text, ((32 - size) / 2 + x, (32 - size) / 2 + y), (0, 0), 0.0, float (size), float (pad), 16#FFFFFFFF#); draw_string (font_array (index), text, (float ((32 - size) / 2 + x), float ((32 - size) / 2 + y)), (0.0, 0.0), 0.0, float (size), float (pad), 16#FFFFFFFF#);
end render_string; end render_string;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
@ -470,7 +472,7 @@ package body core is
begin begin
engine_active := true; engine_active := true;
texture_array := new texture_data_array (0 .. 1600); texture_array := new texture_data_array (0 .. 1600);
sound_array := new sound_data_array (0 .. 2); sound_array := new sound_data_array (0 .. 4);
font_array := new font_data_array (0 .. 4); font_array := new font_data_array (0 .. 4);
-- --
error_callback (7); error_callback (7);
@ -549,7 +551,7 @@ package body core is
-- --
initialize_frame; initialize_frame;
-- --
clear_frame (16#506070FF#); clear_frame (16#FF706050#);
end synchronize; end synchronize;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------

View File

@ -104,18 +104,18 @@ begin
core.play_song (core.import_song (core.c_string ("./song/main_menu.ogg"))); core.play_song (core.import_song (core.c_string ("./song/main_menu.ogg")));
--~attribute.configure; attribute.configure;
--~skill.configure; skill.configure;
--~resource.configure; resource.configure;
--~might.configure; might.configure;
--~magic.configure; magic.configure;
--~item.configure; item.configure;
--~unit.configure; unit.configure;
--~construction.configure; construction.configure;
--~chad.configure; chad.configure;
--~world.configure; world.configure;
--~world.make (world.swamp, 180, 140); world.make (world.swamp, 180, 140);
preview_width := core.window_width - side_panel; preview_width := core.window_width - side_panel;
preview_height := core.window_height; preview_height := core.window_height;
@ -129,25 +129,28 @@ begin
-- --
exit when core.engine_active = false; exit when core.engine_active = false;
-- --
--~if core.cursor_mode = 3 then ui.active := ui.default; else ui.active := ui.steam; end if; if core.cursor_mode = 3 then ui.active := ui.default; else ui.active := ui.steam; end if;
--
core.draw (core.hexagon_fill_sprite, 0, 0);
core.draw (core.hexagon_grid_sprite, 0, 0);
-- --
core.camera.x := core.clip (core.camera.x, 0, world.map.width - preview_width / core.base); core.camera.x := core.clip (core.camera.x, 0, world.map.width - preview_width / core.base);
core.camera.y := core.clip (core.camera.y, 0, world.map.height - preview_height / core.base); core.camera.y := core.clip (core.camera.y, 0, world.map.height - preview_height / core.base);
-- --
--~world.draw (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y - 32, core.signal_mode = core.signal_code'pos (core.signal_g)); world.draw (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y - 32, core.signal_mode = core.signal_code'pos (core.signal_g));
-- --
--~core.draw_central_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y); --~core.draw_central_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y);
--~core.draw_squared_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y); --~core.draw_squared_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y);
--~core.draw_hexagon_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y); --~core.draw_hexagon_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y);
-- --
--~ui.draw_menu (0, 0, preview_width, preview_height - 32, false); ui.draw_menu (0, 0, preview_width, preview_height - 32, false);
--~ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height - 32, true); ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height - 32, true);
--~-- --
--~ui.draw_state_box (preview_width + 32, 32); ui.draw_state_box (preview_width + 32, 32);
-- --
signal_list (core.signal_code'val (core.signal_mode)).all; signal_list (core.signal_code'val (core.signal_mode)).all;
-- --
--~menu_render; menu_render;
-- --
ui.draw_text_box (0, core.window_height - 32, core.window_width, 32); ui.draw_text_box (0, core.window_height - 32, core.window_width, 32);
end loop gameplay; end loop gameplay;