diff --git a/source/attribute.adb b/source/attribute.adb index 071ee5b..0cd6fbe 100644 --- a/source/attribute.adb +++ b/source/attribute.adb @@ -24,13 +24,6 @@ package body attribute is ------------------------------------------------------------------------------------------ - procedure draw (index : in codex; x, y : in integer) is - begin - core.draw (sprite (index), x, y); - end draw; - - ------------------------------------------------------------------------------------------ - procedure menu (x, y : in integer; center : in boolean) is offset : constant integer := 16; width : constant integer := 180 + 2 * offset; @@ -43,8 +36,7 @@ package body attribute is -- for index in codex loop - ui.draw_icon (trait (index).text, move_x + offset, move_y + offset + codex'pos (index) * core.icon); - draw (index, move_x + offset, move_y + offset + codex'pos (index) * core.icon); + ui.draw_icon (sprite (index), trait (index).text, move_x + offset, move_y + offset + codex'pos (index) * core.icon); ui.write (trait (index).name, move_x + offset + core.icon, move_y + offset + codex'pos (index) * core.icon); end loop; end menu; diff --git a/source/attribute.ads b/source/attribute.ads index 1bf6534..9065b51 100644 --- a/source/attribute.ads +++ b/source/attribute.ads @@ -42,8 +42,6 @@ package attribute is procedure configure; - procedure draw (index : in codex; x, y : in integer); - procedure menu (x, y : in integer; center : in boolean); ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/core.adb b/source/core.adb index 8934cac..12655f8 100644 --- a/source/core.adb +++ b/source/core.adb @@ -2,101 +2,14 @@ -- -- GNU General Public Licence (version 3 or later) -with core; +with core, ray; + +use ray; package body core is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - type color_range is range 0 .. 2 ** 8 - 1; - type logical is new boolean; - -- - for logical'size use 32; - for color_range'size use 8; - -- - type trace_log_level is ( - log_all, log_trace, log_debug, log_info, log_warning, log_error, - log_fatal, log_none - ) with convention => c; - -- - type mouse_button is ( - mouse_button_left, mouse_button_right, mouse_button_middle, mouse_button_side, mouse_button_extra, mouse_button_forward, - mouse_button_back - ) with convention => c; - -- - type vessel is record x, y : float; end record with convention => c_pass_by_copy; - type color is record r, g, b, a : color_range; end record with convention => c_pass_by_copy; - type rectangle is record x ,y, width, height : float; end record with convention => c_pass_by_copy; - type texture is record id : natural; width, height, mipmaps, format : integer; end record with convention => c_pass_by_copy; - type font is record base, count, pad : integer; data : texture; r : access rectangle; non : access natural; end record with convention => c_pass_by_copy; - type stream is record buffer, processor : access natural; rate, size, channels : natural; end record with convention => c_pass_by_copy; - type sound is record data : stream; frame : natural; end record with convention => c_pass_by_copy; - -- - procedure open_window (width, height : integer; title : string) with import => true, convention => c, external_name => "InitWindow"; - procedure close_window with import => true, convention => c, external_name => "CloseWindow"; - -- - procedure open_audio_device with import => true, convention => c, external_name => "InitAudioDevice"; - procedure close_audio_device with import => true, convention => c, external_name => "CloseAudioDevice"; - -- - procedure set_exit_key (key : integer) with import => true, convention => c, external_name => "SetExitKey"; - function exit_key_is_pressed return logical with import => true, convention => c, external_name => "WindowShouldClose"; - function get_key_pressed return integer with import => true, convention => c, external_name => "GetKeyPressed"; - function mouse_button_is_pressed (button : mouse_button) return logical with import => true, convention => c, external_name => "IsMouseButtonPressed"; - function mouse_button_is_released (button : mouse_button) return logical with import => true, convention => c, external_name => "IsMouseButtonReleased"; - function get_mouse_x return integer with import => true, convention => c, external_name => "GetMouseX"; - function get_mouse_y return integer with import => true, convention => c, external_name => "GetMouseY"; - function get_mouse_vessel return vessel with import => true, convention => c, external_name => "GetMousePosition"; - function get_screen_width return integer with import => true, convention => c, external_name => "GetScreenWidth"; - function get_screen_height return integer with import => true, convention => c, external_name => "GetScreenHeight"; - -- - procedure clear_background (tint : color) with import => true, convention => c, external_name => "ClearBackground"; - procedure begin_drawing with import => true, convention => c, external_name => "BeginDrawing"; - procedure end_drawing with import => true, convention => c, external_name => "EndDrawing"; - -- - procedure set_target_fps (fps : integer) with import => true, convention => c, external_name => "SetTargetFPS"; - function get_fps return integer with import => true, convention => c, external_name => "GetFPS"; - procedure randomization (seed : natural) with import => true, convention => c, external_name => "SetRandomSeed"; - function get_random (minimum, maximum : integer) return integer with import => true, convention => c, external_name => "GetRandomValue"; - -- - procedure take_screenshot (path : string := "screenshot.png") with import => true, convention => c, external_name => "TakeScreenshot"; - -- - procedure set_trace_log_level (level : trace_log_level) with import => true, convention => c, external_name => "SetTraceLogLevel"; - -- - function load_texture (path : string) return texture with import => true, convention => c, external_name => "LoadTexture"; - function load_sound (path : string) return sound with import => true, convention => c, external_name => "LoadSound"; - function load_font (path : string) return font with import => true, convention => c, external_name => "LoadFont"; - -- - procedure unload_texture (data : texture) with import => true, convention => c, external_name => "UnloadTexture"; - procedure unload_sound (data : sound) with import => true, convention => c, external_name => "UnloadSound"; - procedure unload_font (data : font) with import => true, convention => c, external_name => "UnloadFont"; - -- - procedure draw_line (x0, y0, x1, y1 : integer; tint : color) with import => true, convention => c, external_name => "DrawLine"; - -- - procedure draw_rectangle (x, y, width, height : integer; tint : color) with import => true, convention => c, external_name => "DrawRectangle"; - -- - procedure draw_image (data : texture; uv : rectangle; view : vessel; tint : color) with import => true, convention => c, external_name => "DrawTextureRec"; - -- - procedure draw_text (data : font; text : string; view : vessel; size, pad : float; tint : color) with import => true, convention => c, external_name => "DrawTextEx"; - -- - procedure play_sound (data : sound) with import => true, convention => c, external_name => "PlaySound"; - procedure stop_sound (data : sound) with import => true, convention => c, external_name => "StopSound"; - procedure pause_sound (data : sound) with import => true, convention => c, external_name => "PauseSound"; - procedure resume_sound (data : sound) with import => true, convention => c, external_name => "ResumeSound"; - - procedure megadraw ( - data : texture; - uv : rectangle; - view : rectangle; - origin : vessel; - rotate : float; - tint : color - ) with - import => true, - convention => c, - external_name => "DrawTexturePro"; - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - texture_count : integer := 0; sound_count : integer := 0; font_count : integer := 0; diff --git a/source/core.ads b/source/core.ads index 678689a..a405248 100644 --- a/source/core.ads +++ b/source/core.ads @@ -2,8 +2,8 @@ -- -- GNU General Public Licence (version 3 or later) -with ada.text_io, ada.strings.unbounded, interfaces.c; -use ada.text_io, ada.strings.unbounded, interfaces.c; +with ada.text_io, ada.strings.unbounded; +use ada.text_io, ada.strings.unbounded; package core is diff --git a/source/ray.ads b/source/ray.ads new file mode 100644 index 0000000..fead44d --- /dev/null +++ b/source/ray.ads @@ -0,0 +1,101 @@ +-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic +-- +-- GNU General Public Licence (version 3 or later) + +with interfaces.c; +use interfaces.c; + +package ray is + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + type color_range is range 0 .. 2 ** 8 - 1; + type logical is new boolean; + + for logical'size use 32; + for color_range'size use 8; + + type trace_log_level is ( + log_all, log_trace, log_debug, log_info, log_warning, log_error, + log_fatal, log_none + ) with convention => c; + + type mouse_button is ( + mouse_button_left, mouse_button_right, mouse_button_middle, mouse_button_side, mouse_button_extra, mouse_button_forward, + mouse_button_back + ) with convention => c; + + type vessel is record x, y : float; end record with convention => c_pass_by_copy; + type color is record r, g, b, a : color_range; end record with convention => c_pass_by_copy; + type rectangle is record x ,y, width, height : float; end record with convention => c_pass_by_copy; + type texture is record id : natural; width, height, mipmaps, format : integer; end record with convention => c_pass_by_copy; + type font is record base, count, pad : integer; data : texture; r : access rectangle; non : access natural; end record with convention => c_pass_by_copy; + type stream is record buffer, processor : access natural; rate, size, channels : natural; end record with convention => c_pass_by_copy; + type sound is record data : stream; frame : natural; end record with convention => c_pass_by_copy; + -- + procedure open_window (width, height : integer; title : string) with import => true, convention => c, external_name => "InitWindow"; + procedure close_window with import => true, convention => c, external_name => "CloseWindow"; + -- + procedure open_audio_device with import => true, convention => c, external_name => "InitAudioDevice"; + procedure close_audio_device with import => true, convention => c, external_name => "CloseAudioDevice"; + -- + procedure set_exit_key (key : integer) with import => true, convention => c, external_name => "SetExitKey"; + function exit_key_is_pressed return logical with import => true, convention => c, external_name => "WindowShouldClose"; + function get_key_pressed return integer with import => true, convention => c, external_name => "GetKeyPressed"; + function mouse_button_is_pressed (button : mouse_button) return logical with import => true, convention => c, external_name => "IsMouseButtonPressed"; + function mouse_button_is_released (button : mouse_button) return logical with import => true, convention => c, external_name => "IsMouseButtonReleased"; + function get_mouse_x return integer with import => true, convention => c, external_name => "GetMouseX"; + function get_mouse_y return integer with import => true, convention => c, external_name => "GetMouseY"; + function get_mouse_vessel return vessel with import => true, convention => c, external_name => "GetMousePosition"; + function get_screen_width return integer with import => true, convention => c, external_name => "GetScreenWidth"; + function get_screen_height return integer with import => true, convention => c, external_name => "GetScreenHeight"; + -- + procedure clear_background (tint : color) with import => true, convention => c, external_name => "ClearBackground"; + procedure begin_drawing with import => true, convention => c, external_name => "BeginDrawing"; + procedure end_drawing with import => true, convention => c, external_name => "EndDrawing"; + -- + procedure set_target_fps (fps : integer) with import => true, convention => c, external_name => "SetTargetFPS"; + function get_fps return integer with import => true, convention => c, external_name => "GetFPS"; + procedure randomization (seed : natural) with import => true, convention => c, external_name => "SetRandomSeed"; + function get_random (minimum, maximum : integer) return integer with import => true, convention => c, external_name => "GetRandomValue"; + -- + procedure take_screenshot (path : string := "screenshot.png") with import => true, convention => c, external_name => "TakeScreenshot"; + -- + procedure set_trace_log_level (level : trace_log_level) with import => true, convention => c, external_name => "SetTraceLogLevel"; + -- + function load_texture (path : string) return texture with import => true, convention => c, external_name => "LoadTexture"; + function load_sound (path : string) return sound with import => true, convention => c, external_name => "LoadSound"; + function load_font (path : string) return font with import => true, convention => c, external_name => "LoadFont"; + -- + procedure unload_texture (data : texture) with import => true, convention => c, external_name => "UnloadTexture"; + procedure unload_sound (data : sound) with import => true, convention => c, external_name => "UnloadSound"; + procedure unload_font (data : font) with import => true, convention => c, external_name => "UnloadFont"; + -- + procedure draw_line (x0, y0, x1, y1 : integer; tint : color) with import => true, convention => c, external_name => "DrawLine"; + -- + procedure draw_rectangle (x, y, width, height : integer; tint : color) with import => true, convention => c, external_name => "DrawRectangle"; + -- + procedure draw_image (data : texture; uv : rectangle; view : vessel; tint : color) with import => true, convention => c, external_name => "DrawTextureRec"; + -- + procedure draw_text (data : font; text : string; view : vessel; size, pad : float; tint : color) with import => true, convention => c, external_name => "DrawTextEx"; + -- + procedure play_sound (data : sound) with import => true, convention => c, external_name => "PlaySound"; + procedure stop_sound (data : sound) with import => true, convention => c, external_name => "StopSound"; + procedure pause_sound (data : sound) with import => true, convention => c, external_name => "PauseSound"; + procedure resume_sound (data : sound) with import => true, convention => c, external_name => "ResumeSound"; + + procedure megadraw ( + data : texture; + uv : rectangle; + view : rectangle; + origin : vessel; + rotate : float; + tint : color + ) with + import => true, + convention => c, + external_name => "DrawTexturePro"; + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + +end ray; diff --git a/source/resource.adb b/source/resource.adb index 804848f..05d327f 100644 --- a/source/resource.adb +++ b/source/resource.adb @@ -24,13 +24,6 @@ package body resource is ------------------------------------------------------------------------------------------ - procedure draw (index : in codex; x, y : in integer) is - begin - core.draw (sprite (index), x, y); - end draw; - - ------------------------------------------------------------------------------------------ - procedure menu (x, y : in integer; center : in boolean) is offset : constant integer := 16; width : constant integer := 180 + 2 * offset; @@ -43,8 +36,7 @@ package body resource is -- for index in codex loop - ui.draw_icon (trait (index).text, move_x + offset, move_y + offset + codex'pos (index) * core.icon); - draw (index, move_x + offset, move_y + offset + codex'pos (index) * core.icon); + ui.draw_icon (sprite (index), trait (index).text, move_x + offset, move_y + offset + codex'pos (index) * core.icon); ui.write (trait (index).name, move_x + offset + core.icon, move_y + offset + codex'pos (index) * core.icon); end loop; end menu; diff --git a/source/resource.ads b/source/resource.ads index 9c8bd5d..1035472 100644 --- a/source/resource.ads +++ b/source/resource.ads @@ -42,8 +42,6 @@ package resource is procedure configure; - procedure draw (index : in codex; x, y : in integer); - procedure menu (x, y : in integer; center : in boolean); ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/skill.adb b/source/skill.adb index 509bb03..dc3e283 100644 --- a/source/skill.adb +++ b/source/skill.adb @@ -24,13 +24,6 @@ package body skill is ------------------------------------------------------------------------------------------ - procedure draw (index : in codex; x, y : in integer) is - begin - core.draw (sprite (index), x, y); - end draw; - - ------------------------------------------------------------------------------------------ - procedure menu (x, y : in integer; center : in boolean) is column : constant integer := 2; offset : constant integer := 16; @@ -44,8 +37,7 @@ package body skill is -- for index in codex loop - ui.draw_icon (trait (index).text, move_x + 216 * (codex'pos (index) mod column) + offset, move_y + core.icon * (codex'pos (index) / column) + offset); - draw (index, move_x + 216 * (codex'pos (index) mod column) + offset, move_y + core.icon * (codex'pos (index) / column) + offset); + ui.draw_icon (sprite (index), trait (index).text, move_x + 216 * (codex'pos (index) mod column) + offset, move_y + core.icon * (codex'pos (index) / column) + offset); ui.write (trait (index).name, move_x + 216 * (codex'pos (index) mod column) + offset + core.icon, move_y + core.icon * (codex'pos (index) / column) + offset); end loop; end menu; diff --git a/source/skill.ads b/source/skill.ads index 7ed2530..9810bf5 100644 --- a/source/skill.ads +++ b/source/skill.ads @@ -49,8 +49,6 @@ package skill is procedure configure; - procedure draw (index : in codex; x, y : in integer); - procedure menu (x, y : in integer; center : in boolean); ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/ui.adb b/source/ui.adb index 0acc375..6ea2f80 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -112,10 +112,15 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw_icon (description : in string; x, y : in integer) is + procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer) is begin draw (icon, x, y); select_text_box (description, x, y, core.icon, core.icon); + -- + core.zoom := 1.0; + core.draw (data, x, y); + core.zoom := 2.0; + -- end draw_icon; ------------------------------------------------------------------------------------------ diff --git a/source/ui.ads b/source/ui.ads index 1beb46b..c6c10b8 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -42,7 +42,7 @@ package ui is procedure configure; - procedure draw_icon (description : in string; x, y : in integer); + procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer); procedure draw_overicon (description : in string; x, y : in integer); procedure draw_text_box (x, y, width, height : in integer); diff --git a/source/unit.adb b/source/unit.adb index 565309a..b3a0f6b 100644 --- a/source/unit.adb +++ b/source/unit.adb @@ -95,15 +95,14 @@ package body unit is -- view (index, move_x + offset, move_y + offset); -- - for data in attribute.codex - loop - move := attribute.codex'pos (data) * core.icon; - -- - ui.draw_icon (attribute.trait (data).text, move_x + view_width + 12 + offset, move_y + offset + move); - attribute.draw (data, move_x + view_width + 12 + offset, move_y + offset + move); - -- - ui.write (trait (index).attributes (data)'image, move_x + view_width + 12 + offset + core.icon, move_y + offset + move); - end loop; + --~for data in attribute.codex + --~loop + --~move := attribute.codex'pos (data) * core.icon; + --~-- + --~ui.draw_icon (attribute.sprite (data), attribute.trait (data).text, move_x + view_width + 12 + offset, move_y + offset + move); + --~-- + --~ui.write (trait (index).attributes (data)'image, move_x + view_width + 12 + offset + core.icon, move_y + offset + move); + --~end loop; -- for animate in animation loop