2024-04-25 00:27:13 -04:00
|
|
|
-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
|
|
|
|
--
|
|
|
|
-- GNU General Public Licence (version 3 or later)
|
|
|
|
|
2024-05-08 15:43:44 -04:00
|
|
|
with ray;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
2024-04-25 09:26:08 -04:00
|
|
|
package body core is
|
2024-04-25 04:14:45 -04:00
|
|
|
|
2024-03-20 05:11:34 -04:00
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
type terminal_colour is (
|
|
|
|
grey, red, green, yellow, blue, pink,
|
|
|
|
cyan, white
|
|
|
|
);
|
|
|
|
|
|
|
|
type terminal_effect is (
|
|
|
|
normal, bold, italic, underline, blink, invert
|
|
|
|
);
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
2024-03-17 15:15:18 -04:00
|
|
|
|
2024-04-26 10:33:17 -04:00
|
|
|
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;
|
2024-03-17 16:08:50 -04:00
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
texture_count : integer := 0;
|
|
|
|
sound_count : integer := 0;
|
|
|
|
font_count : integer := 0;
|
|
|
|
|
2024-03-17 16:08:50 -04:00
|
|
|
texture_array : access texture_data_array;
|
|
|
|
sound_array : access sound_data_array;
|
|
|
|
font_array : access font_data_array;
|
2024-03-17 15:15:18 -04:00
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
2024-03-17 15:15:18 -04:00
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
procedure terminal (colour : in terminal_colour := white;
|
|
|
|
effect : in terminal_effect := normal) is
|
2024-03-11 08:42:25 -04:00
|
|
|
format : string := character'val (27) & "[" & character'val (terminal_effect'pos (effect) + 48) & ";3" & character'val (terminal_colour'pos (colour) + 48) & "m";
|
|
|
|
begin
|
|
|
|
put (format);
|
|
|
|
end terminal;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
procedure echo (status : in echo_status;
|
|
|
|
text : in string) is
|
2024-03-11 08:42:25 -04:00
|
|
|
begin
|
2024-03-21 19:03:15 -04:00
|
|
|
if not echo_mark (status) then
|
|
|
|
return;
|
|
|
|
end if;
|
2024-03-11 08:42:25 -04:00
|
|
|
--
|
2024-03-21 18:28:26 -04:00
|
|
|
put ("[");
|
2024-03-11 08:42:25 -04:00
|
|
|
case status is
|
2024-04-27 10:01:54 -04:00
|
|
|
when failure => terminal (red, bold); put ("Failure"); terminal;
|
|
|
|
when warning => terminal (yellow, bold); put ("Warning"); terminal;
|
|
|
|
when success => terminal (green, bold); put ("Success"); terminal;
|
|
|
|
when comment => terminal (grey, bold); put ("Comment"); terminal;
|
|
|
|
when import => terminal (cyan, bold); put (" <-- "); terminal;
|
|
|
|
when export => terminal (blue, bold); put (" --> "); terminal;
|
|
|
|
end case;
|
2024-04-27 09:04:47 -04:00
|
|
|
put ("] ");
|
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
put_line (text);
|
2024-03-11 08:42:25 -04:00
|
|
|
end echo;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure dash is
|
|
|
|
begin
|
|
|
|
terminal (grey, bold);
|
|
|
|
put ("------------------------------------------------------------------------------------------");
|
|
|
|
put ("------------------------------------------------------------------------------------------");
|
|
|
|
terminal;
|
|
|
|
new_line;
|
|
|
|
end dash;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure semi_dash is
|
|
|
|
begin
|
|
|
|
terminal (grey, bold);
|
|
|
|
put (" ");
|
|
|
|
put ("------------------------------------------------------------------------------------------");
|
|
|
|
terminal;
|
|
|
|
new_line;
|
|
|
|
end semi_dash;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
function c_string (ada_string : string) return string is
|
|
|
|
begin
|
|
|
|
return (ada_string & character'val (0));
|
|
|
|
end c_string;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-26 11:05:19 -04:00
|
|
|
function random (minimum, maximum : in integer) return integer is
|
2024-03-17 15:15:18 -04:00
|
|
|
begin
|
2024-04-26 10:33:17 -04:00
|
|
|
return ray.get_random (minimum, maximum);
|
2024-04-26 11:05:19 -04:00
|
|
|
end random;
|
2024-03-17 15:15:18 -04:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-02-20 10:26:49 -05:00
|
|
|
function clip (value, minimum, maximum : in integer) return integer is
|
|
|
|
begin
|
2024-04-27 10:01:54 -04:00
|
|
|
if value < minimum then return minimum; end if;
|
|
|
|
if value > maximum then return maximum; end if;
|
|
|
|
--
|
2024-02-20 10:26:49 -05:00
|
|
|
return value;
|
|
|
|
end clip;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-08 18:34:49 -04:00
|
|
|
function lowercase (text : in string) return string is
|
|
|
|
result : string (1 .. text'length);
|
|
|
|
begin
|
|
|
|
for index in text'range loop
|
|
|
|
if text (index) in 'A' .. 'Z' then
|
|
|
|
result (index) := character'val (character'pos (text (index)) + 32);
|
|
|
|
else
|
|
|
|
result (index) := text (index);
|
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
return result;
|
|
|
|
end lowercase;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 03:53:38 -04:00
|
|
|
function center_x (object : in integer) return integer is begin return (window_width - object) / 2; end center_x;
|
|
|
|
function center_y (object : in integer) return integer is begin return (window_height - object) / 2; end center_y;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function cursor_inside (x, y, width, height : in integer) return boolean is
|
|
|
|
begin
|
|
|
|
return cursor.x > x and cursor.x < x + width and cursor.y > y and cursor.y < y + height;
|
|
|
|
end cursor_inside;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-03-17 16:45:46 -04:00
|
|
|
function import_sprite (file_path : in string; frames, states : in integer) return sprite is
|
2024-02-15 21:03:09 -05:00
|
|
|
this : sprite;
|
|
|
|
begin
|
2024-04-26 10:33:17 -04:00
|
|
|
texture_array (texture_count) := ray.load_texture (c_string (file_path));
|
2024-03-17 16:45:46 -04:00
|
|
|
--
|
|
|
|
texture_count := texture_count + 1;
|
|
|
|
this.index := texture_count - 1;
|
2024-04-27 07:03:40 -04:00
|
|
|
this.width := texture_array (this.index).width / frames;
|
|
|
|
this.height := texture_array (this.index).height / states;
|
2024-03-17 16:45:46 -04:00
|
|
|
this.frames := frames;
|
|
|
|
this.states := states;
|
2024-02-15 21:03:09 -05:00
|
|
|
--
|
2024-04-25 03:46:07 -04:00
|
|
|
if this.width = 0 or this.height = 0 then
|
2024-04-27 07:03:40 -04:00
|
|
|
echo (failure, "Sprite not imported: " & file_path);
|
2024-04-25 03:46:07 -04:00
|
|
|
end if;
|
|
|
|
--
|
2024-02-15 21:03:09 -05:00
|
|
|
return this;
|
2024-03-17 16:45:46 -04:00
|
|
|
end import_sprite;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
function import_font (file_path : in string; scale, space : in integer) return font is
|
|
|
|
this : font;
|
2024-03-14 06:06:22 -04:00
|
|
|
begin
|
2024-04-26 10:33:17 -04:00
|
|
|
font_array (font_count) := ray.load_font (c_string (file_path));
|
2024-03-17 16:45:46 -04:00
|
|
|
--
|
|
|
|
font_count := font_count + 1;
|
|
|
|
this.index := font_count - 1;
|
2024-04-26 18:25:29 -04:00
|
|
|
this.scale := scale;
|
|
|
|
this.space := space;
|
2024-03-14 06:06:22 -04:00
|
|
|
--
|
|
|
|
return this;
|
2024-04-26 18:25:29 -04:00
|
|
|
end import_font;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
function import_song (file_path : in string) return song is
|
|
|
|
this : song;
|
2024-02-20 12:32:41 -05:00
|
|
|
begin
|
2024-04-26 18:25:29 -04:00
|
|
|
sound_array (sound_count) := ray.load_sound (c_string (file_path));
|
2024-02-20 14:02:50 -05:00
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
sound_count := sound_count + 1;
|
|
|
|
this.index := sound_count - 1;
|
2024-02-20 12:32:41 -05:00
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
return this;
|
|
|
|
end import_song;
|
2024-02-20 12:32:41 -05:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 02:08:01 -04:00
|
|
|
procedure draw (data : in sprite := (others => 0);
|
|
|
|
x : in integer := 0;
|
|
|
|
y : in integer := 0;
|
|
|
|
u : in integer := 0;
|
|
|
|
v : in integer := 0;
|
|
|
|
width : in integer := 0;
|
|
|
|
height : in integer := 0;
|
|
|
|
state : in integer := 0;
|
|
|
|
factor : in integer := zoom;
|
|
|
|
tint : in colour := (others => 255)) is
|
2024-05-08 19:30:00 -04:00
|
|
|
new_width : constant float := float ((if width = 0 then data.width else width));
|
|
|
|
new_height : constant float := float ((if height = 0 then data.height else height));
|
2024-05-09 02:08:01 -04:00
|
|
|
--
|
|
|
|
new_tint : ray.colour := (ray.colour_range (tint.r), ray.colour_range (tint.g), ray.colour_range (tint.b), ray.colour_range (tint.a));
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-04-27 07:03:40 -04:00
|
|
|
ray.draw_texture (data => texture_array (data.index),
|
2024-05-09 05:07:20 -04:00
|
|
|
uv => (x => float (if u > 0 then u else (animation_time mod data.frames) * data.width),
|
|
|
|
y => float (if state = 0 then v else (state mod data.states) * data.height),
|
|
|
|
width => new_width,
|
|
|
|
height => new_height),
|
|
|
|
view => (x => float (x),
|
|
|
|
y => float (y),
|
|
|
|
width => new_width * float (factor),
|
|
|
|
height => new_height * float (factor)),
|
|
|
|
tint => new_tint);
|
2024-02-15 21:03:09 -05:00
|
|
|
end draw;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 06:16:11 -04:00
|
|
|
procedure draw_horizontally (data : in sprite; x, y, width : in integer) is
|
|
|
|
begin
|
|
|
|
for move in 0 .. width / data.width - 1 loop
|
|
|
|
draw (data, x + move * data.width, y);
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
if width mod data.width > 0 then
|
|
|
|
draw (data, x + (width / data.width) * data.width, y, width mod data.width, data.height);
|
|
|
|
end if;
|
|
|
|
end draw_horizontally;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure draw_vertically (data : in sprite; x, y, height : in integer) is
|
|
|
|
begin
|
|
|
|
for move in 0 .. height / data.height - 1 loop
|
|
|
|
draw (data, x, y + move * data.height);
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
if height mod data.height > 0 then
|
|
|
|
draw (data, x, y + (height / data.height) * data.height, data.width, height mod data.height);
|
|
|
|
end if;
|
|
|
|
end draw_vertically;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
procedure write (text : in string := "";
|
|
|
|
x : in integer := 0;
|
|
|
|
y : in integer := 0;
|
2024-05-09 02:08:01 -04:00
|
|
|
tint : in colour := (others => 255);
|
|
|
|
size : in integer := 0;
|
|
|
|
data : in font := (others => 0)) is
|
|
|
|
new_tint : ray.colour := (ray.colour_range (tint.r), ray.colour_range (tint.g), ray.colour_range (tint.b), ray.colour_range (tint.a));
|
2024-02-19 14:21:24 -05:00
|
|
|
begin
|
2024-04-26 18:25:29 -04:00
|
|
|
ray.draw_text (data => font_array (data.index),
|
|
|
|
text => c_string (text),
|
2024-05-09 02:08:01 -04:00
|
|
|
view => (float (x), float (y)),
|
2024-05-09 03:53:38 -04:00
|
|
|
scale => (if size = 0 then float (font_array (data.index).base) else float (size)),
|
|
|
|
space => float (font_array (data.index).pad),
|
2024-05-09 02:08:01 -04:00
|
|
|
tint => new_tint);
|
2024-02-15 21:03:09 -05:00
|
|
|
end write;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-08 18:34:49 -04:00
|
|
|
procedure play (index : in integer) is begin ray.play_sound (sound_array (index)); end play;
|
|
|
|
procedure stop (index : in integer) is begin ray.stop_sound (sound_array (index)); end stop;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure overlay is
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-05-08 18:34:49 -04:00
|
|
|
ray.draw_rectangle (0, 0, window_width, window_height, (0, 0, 0, 127));
|
|
|
|
end overlay;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure block_queue (data : in block) is
|
|
|
|
begin
|
|
|
|
if block_count = block_limit - 1 then
|
|
|
|
return;
|
|
|
|
end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
--
|
2024-05-08 18:34:49 -04:00
|
|
|
block_array (block_count) := data;
|
|
|
|
--
|
|
|
|
increment (block_count);
|
|
|
|
end block_queue;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-03-13 14:07:17 -04:00
|
|
|
function read_text_box return string is
|
|
|
|
begin
|
|
|
|
return to_string (text_box.data);
|
|
|
|
end read_text_box;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure write_text_box (text : in string) is
|
|
|
|
begin
|
|
|
|
text_box.data := to_unbounded_string (text);
|
|
|
|
end write_text_box;
|
|
|
|
|
2024-03-17 15:15:18 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-08 18:34:49 -04:00
|
|
|
procedure increment (value : in out integer) is begin value := value + 1; end increment;
|
|
|
|
procedure decrement (value : in out integer) is begin value := value - 1; end decrement;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 05:07:20 -04:00
|
|
|
procedure idle_skip is begin null; end idle_skip;
|
2024-05-08 18:34:49 -04:00
|
|
|
|
|
|
|
procedure move_camera_up is begin core.camera.y := core.camera.y - 1; end move_camera_up;
|
|
|
|
procedure move_camera_down is begin core.camera.y := core.camera.y + 1; end move_camera_down;
|
|
|
|
procedure move_camera_left is begin core.camera.x := core.camera.x - 1; end move_camera_left;
|
|
|
|
procedure move_camera_right is begin core.camera.x := core.camera.x + 1; end move_camera_right;
|
2024-03-17 15:15:18 -04:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
2024-03-24 07:46:56 -04:00
|
|
|
|
2024-03-17 15:15:18 -04:00
|
|
|
procedure initialize is
|
|
|
|
begin
|
2024-04-26 10:33:17 -04:00
|
|
|
echo (comment, "Initializing core components...");
|
2024-03-21 18:28:26 -04:00
|
|
|
--
|
2024-03-17 15:15:18 -04:00
|
|
|
engine_active := true;
|
2024-03-17 16:08:50 -04:00
|
|
|
texture_array := new texture_data_array (0 .. 1600);
|
2024-03-17 17:52:59 -04:00
|
|
|
sound_array := new sound_data_array (0 .. 4);
|
2024-04-30 19:58:38 -04:00
|
|
|
font_array := new font_data_array (0 .. 8);
|
2024-03-17 15:15:18 -04:00
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
echo (comment, "-- Setting trace log level to none (ignoring all default Raylib logs).");
|
2024-04-26 10:33:17 -04:00
|
|
|
ray.set_trace_log_level (ray.log_none);
|
2024-05-01 15:19:12 -04:00
|
|
|
--
|
|
|
|
ray.set_window_flags (ray.flag_window_resizable);
|
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
echo (comment, "-- Initializing Raylib window data...");
|
|
|
|
echo (comment, "-- -- Window title : Chads of Might & Magic");
|
|
|
|
echo (comment, "-- -- Window width : 1800");
|
|
|
|
echo (comment, "-- -- Window height : 900");
|
2024-04-26 10:33:17 -04:00
|
|
|
ray.open_window (1800, 900, "Chads of Might & Magic");
|
2024-05-01 15:19:12 -04:00
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
echo (comment, "-- Initializing Raylib audio device data...");
|
2024-04-26 10:33:17 -04:00
|
|
|
ray.open_audio_device;
|
2024-03-17 15:15:18 -04:00
|
|
|
--
|
2024-04-27 07:03:40 -04:00
|
|
|
ray.randomization (19970725);
|
2024-04-26 10:33:17 -04:00
|
|
|
ray.set_target_fps (60);
|
2024-03-17 16:08:50 -04:00
|
|
|
--
|
2024-04-26 10:33:17 -04:00
|
|
|
echo (success, "Initialized core components.");
|
2024-03-17 15:15:18 -04:00
|
|
|
end initialize;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure deinitialize is
|
|
|
|
begin
|
2024-04-26 10:33:17 -04:00
|
|
|
echo (comment, "Deinitializing core components...");
|
2024-03-21 18:28:26 -04:00
|
|
|
--
|
2024-03-17 15:15:18 -04:00
|
|
|
engine_active := false;
|
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
echo (comment, "-- -- Unloading Raylib" & texture_count'image & " textures.");
|
|
|
|
echo (comment, "-- -- Unloading Raylib" & sound_count'image & " sounds.");
|
|
|
|
echo (comment, "-- -- Unloading Raylib" & font_count'image & " fonts.");
|
2024-03-21 18:28:26 -04:00
|
|
|
--
|
2024-04-26 10:33:17 -04:00
|
|
|
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;
|
2024-03-17 15:15:18 -04:00
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
echo (comment, "-- Deinitializing Raylib audio device data...");
|
2024-04-26 10:33:17 -04:00
|
|
|
ray.close_audio_device;
|
2024-03-21 18:28:26 -04:00
|
|
|
--
|
2024-04-26 18:25:29 -04:00
|
|
|
echo (comment, "-- Deinitializing Raylib window data...");
|
2024-04-26 10:33:17 -04:00
|
|
|
ray.close_window;
|
2024-03-21 18:28:26 -04:00
|
|
|
--
|
2024-04-26 10:33:17 -04:00
|
|
|
echo (success, "Deinitialized core components.");
|
2024-03-17 15:15:18 -04:00
|
|
|
end deinitialize;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure synchronize is
|
|
|
|
signal : integer := signal_code'pos (signal_none);
|
|
|
|
begin
|
|
|
|
global_time := global_time + 1;
|
|
|
|
global_time := global_time mod (gameplay_framerate * animation_framerate);
|
|
|
|
gameplay_time := global_time mod (gameplay_framerate);
|
|
|
|
animation_time := global_time / (gameplay_framerate / animation_framerate);
|
2024-04-26 10:33:17 -04:00
|
|
|
framerate := integer (ray.get_fps);
|
|
|
|
signal := ray.get_key_pressed;
|
|
|
|
cursor.x := ray.get_mouse_x;
|
|
|
|
cursor.y := ray.get_mouse_y;
|
2024-03-17 15:15:18 -04:00
|
|
|
--
|
2024-04-26 10:33:17 -04:00
|
|
|
ray.end_drawing;
|
2024-03-17 15:15:18 -04:00
|
|
|
--
|
2024-04-26 10:33:17 -04:00
|
|
|
if ray.exit_key_is_pressed then
|
2024-03-17 15:15:18 -04:00
|
|
|
engine_active := false;
|
|
|
|
end if;
|
|
|
|
--
|
2024-04-26 10:33:17 -04:00
|
|
|
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;
|
2024-03-17 15:15:18 -04:00
|
|
|
--
|
|
|
|
case signal is
|
2024-05-08 16:17:47 -04:00
|
|
|
when 48 .. 57 => signal_mode := signal_code'val (signal - 48 + signal_code'pos (signal_0));
|
|
|
|
when 65 .. 90 => signal_mode := signal_code'val (signal - 65 + signal_code'pos (signal_a));
|
|
|
|
when 320 .. 329 => signal_mode := signal_code'val (signal - 320 + signal_code'pos (signal_kp_0));
|
2024-03-17 15:15:18 -04:00
|
|
|
--
|
2024-05-08 16:17:47 -04:00
|
|
|
when 0 => signal_mode := signal_none;
|
|
|
|
when 32 => signal_mode := signal_space;
|
|
|
|
when 96 => signal_mode := signal_grave;
|
|
|
|
when 340 => signal_mode := signal_left_shift;
|
|
|
|
when 341 => signal_mode := signal_left_control;
|
|
|
|
when 333 => signal_mode := signal_kp_subtract;
|
|
|
|
when 334 => signal_mode := signal_kp_add;
|
|
|
|
when 256 => signal_mode := signal_escape;
|
|
|
|
when 257 => signal_mode := signal_enter;
|
|
|
|
when 258 => signal_mode := signal_tab;
|
|
|
|
when 259 => signal_mode := signal_backspace;
|
|
|
|
when 262 => signal_mode := signal_right;
|
|
|
|
when 263 => signal_mode := signal_left;
|
|
|
|
when 264 => signal_mode := signal_down;
|
|
|
|
when 265 => signal_mode := signal_up;
|
|
|
|
when others => signal_mode := signal_none;
|
2024-03-17 15:15:18 -04:00
|
|
|
end case;
|
|
|
|
--
|
2024-05-04 08:40:03 -04:00
|
|
|
--~for index in reverse 0 .. block_count - 1 loop
|
|
|
|
--~if core.cursor.x > block_array (index).x and core.cursor.x < block_array (index).width
|
|
|
|
--~and core.cursor.y > block_array (index).y and core.cursor.y < block_array (index).height
|
|
|
|
--~and core.cursor_mode = block_array (index).mode then
|
|
|
|
--~block_array (index).action.all;
|
|
|
|
--~core.cursor_mode := 0;
|
|
|
|
--~exit;
|
|
|
|
--~end if;
|
|
|
|
--~end loop;
|
2024-05-04 08:26:51 -04:00
|
|
|
--
|
|
|
|
block_count := 0;
|
|
|
|
--
|
2024-04-26 10:33:17 -04:00
|
|
|
ray.begin_drawing;
|
2024-03-17 15:15:18 -04:00
|
|
|
--
|
2024-05-08 15:33:13 -04:00
|
|
|
ray.clear_background ((0, 0, 0, 255));
|
2024-03-17 15:15:18 -04:00
|
|
|
end synchronize;
|
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
end core;
|