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-23 08:29:21 -04:00
|
|
|
with ada.text_io, ada.strings.unbounded, interfaces.c, ray, system;
|
|
|
|
use ada.text_io, ada.strings.unbounded, interfaces.c, ray, system;
|
|
|
|
|
|
|
|
with ada.sequential_io;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
|
|
|
package core is
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2024-03-11 08:42:25 -04:00
|
|
|
type echo_status is (
|
2024-04-26 18:25:29 -04:00
|
|
|
failure, warning, success, comment, import, export
|
2024-03-11 08:42:25 -04:00
|
|
|
);
|
|
|
|
|
2024-05-19 15:06:20 -04:00
|
|
|
type cursor_code is (
|
|
|
|
cursor_none, cursor_left, cursor_right, cursor_middle
|
|
|
|
);
|
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
type signal_code is (
|
2024-03-17 15:15:18 -04:00
|
|
|
signal_none, signal_space, signal_0, signal_1, signal_2, signal_3,
|
|
|
|
signal_4, signal_5, signal_6, signal_7, signal_8, signal_9,
|
2024-02-15 21:03:09 -05:00
|
|
|
signal_a, signal_b, signal_c, signal_d, signal_e, signal_f,
|
|
|
|
signal_g, signal_h, signal_i, signal_j, signal_k, signal_l,
|
|
|
|
signal_m, signal_n, signal_o, signal_p, signal_q, signal_r,
|
|
|
|
signal_s, signal_t, signal_u, signal_v, signal_w, signal_x,
|
|
|
|
signal_y, signal_z, signal_grave, signal_escape, signal_enter, signal_tab,
|
|
|
|
signal_backspace, signal_right, signal_left, signal_down, signal_up, signal_kp_0,
|
|
|
|
signal_kp_1, signal_kp_2, signal_kp_3, signal_kp_4, signal_kp_5, signal_kp_6,
|
|
|
|
signal_kp_7, signal_kp_8, signal_kp_9, signal_kp_subtract, signal_kp_add, signal_left_shift,
|
2024-05-22 21:05:19 -04:00
|
|
|
signal_left_control, signal_f1, signal_f2, signal_f3, signal_f4, signal_f5,
|
|
|
|
signal_f6, signal_f7, signal_f8, signal_f9, signal_f10, signal_f11,
|
|
|
|
signal_f12
|
2024-02-15 21:03:09 -05:00
|
|
|
);
|
|
|
|
|
2024-05-09 05:07:20 -04:00
|
|
|
type animation is (
|
|
|
|
idle, walk, melee, shoot, wounded, dead
|
|
|
|
);
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 02:08:01 -04:00
|
|
|
type colour_range is range 0 .. 2 ** 8 - 1;
|
|
|
|
|
|
|
|
for colour_range'size use 8;
|
|
|
|
|
|
|
|
type colour is record r, g, b, a : colour_range; end record;
|
|
|
|
|
2024-03-13 14:07:17 -04:00
|
|
|
subtype short_string is string (1 .. 24);
|
|
|
|
subtype long_string is string (1 .. 72);
|
2024-02-15 21:03:09 -05:00
|
|
|
|
2024-05-01 00:16:19 -04:00
|
|
|
type pointer is access procedure;
|
2024-03-16 06:35:03 -04:00
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
type vector is record x, y : integer; end record;
|
|
|
|
type sprite is record index, width, height, frames, states : integer; end record;
|
|
|
|
type font is record index, scale, space : integer; end record;
|
|
|
|
type song is record index : integer; end record;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
2024-05-19 15:06:20 -04:00
|
|
|
type point is record
|
|
|
|
value, limit : natural;
|
2024-05-04 08:26:51 -04:00
|
|
|
end record;
|
|
|
|
|
2024-05-11 06:01:07 -04:00
|
|
|
type string_box_data is record
|
2024-05-10 22:09:30 -04:00
|
|
|
data : access string := null;
|
|
|
|
text : unbounded_string := null_unbounded_string;
|
|
|
|
size : vector := (0, 0);
|
2024-03-13 14:07:17 -04:00
|
|
|
end record;
|
|
|
|
|
2024-05-25 03:00:30 -04:00
|
|
|
package io is new ada.sequential_io (integer);
|
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-18 15:16:09 -04:00
|
|
|
folder : constant string := ".";
|
|
|
|
|
2024-03-10 16:41:31 -04:00
|
|
|
icon : constant natural := 32;
|
2024-04-25 03:46:07 -04:00
|
|
|
base : constant natural := 16;
|
2024-02-15 21:03:09 -05:00
|
|
|
gameplay_framerate : constant natural := 60;
|
2024-04-26 18:25:29 -04:00
|
|
|
animation_framerate : constant natural := 4;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
2024-03-21 18:28:26 -04:00
|
|
|
echo_mark : constant array (echo_status) of boolean := (
|
|
|
|
failure => true,
|
|
|
|
warning => true,
|
|
|
|
success => true,
|
|
|
|
comment => true,
|
2024-05-03 08:16:50 -04:00
|
|
|
import => true,
|
|
|
|
export => true
|
2024-03-21 18:28:26 -04:00
|
|
|
);
|
|
|
|
|
2024-03-17 15:15:18 -04:00
|
|
|
engine_active : boolean := false;
|
|
|
|
|
2024-05-08 16:17:47 -04:00
|
|
|
cursor : vector := (0, 0);
|
|
|
|
camera : vector := (0, 0);
|
2024-05-19 15:06:20 -04:00
|
|
|
cursor_mode : cursor_code := cursor_none;
|
2024-05-08 16:17:47 -04:00
|
|
|
signal_mode : signal_code := signal_none;
|
|
|
|
framerate : integer := 0;
|
|
|
|
global_time : natural := 0;
|
|
|
|
gameplay_time : natural := 0;
|
|
|
|
animation_time : natural := 0;
|
2024-05-08 19:30:00 -04:00
|
|
|
|
2024-05-13 09:32:49 -04:00
|
|
|
wheel : float := 0.0;
|
|
|
|
|
2024-05-08 19:30:00 -04:00
|
|
|
zoom : natural := 1;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
2024-05-11 06:01:07 -04:00
|
|
|
help_box : string_box_data;
|
|
|
|
text_box : string_box_data;
|
2024-03-13 14:07:17 -04:00
|
|
|
|
2024-05-22 21:05:19 -04:00
|
|
|
global_image : ray.image;
|
2024-05-09 15:54:39 -04:00
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-19 15:06:20 -04:00
|
|
|
function "=" (a, b : in signal_code) return boolean;
|
|
|
|
function "=" (a, b : in cursor_code) return boolean;
|
|
|
|
function "/" (a, b : in signal_code) return boolean;
|
|
|
|
function "/" (a, b : in cursor_code) return boolean;
|
|
|
|
|
2024-05-16 12:35:36 -04:00
|
|
|
function "+" (data : in point; modifier : in natural) return point;
|
|
|
|
function "-" (data : in point; modifier : in natural) return point;
|
|
|
|
function "*" (data : in point; modifier : in natural) return point;
|
|
|
|
function "/" (data : in point; modifier : in natural) return point;
|
|
|
|
|
2024-05-19 13:29:28 -04:00
|
|
|
procedure echo ( status : in echo_status; text : in string);
|
|
|
|
procedure echo_when (condition : in boolean; status : in echo_status; text : in string);
|
2024-03-11 08:42:25 -04:00
|
|
|
|
|
|
|
procedure dash;
|
|
|
|
procedure semi_dash;
|
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
function c_string (ada_string : in string) return string;
|
2024-02-20 10:26:49 -05:00
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
function random (minimum, maximum : in integer) return integer;
|
|
|
|
function clip (value, minimum, maximum : in integer) return integer;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
|
|
|
function lowercase (text : in string) return string;
|
2024-03-13 14:07:17 -04:00
|
|
|
|
2024-03-17 15:15:18 -04:00
|
|
|
function window_width return integer;
|
|
|
|
function window_height return integer;
|
|
|
|
|
2024-05-09 03:53:38 -04:00
|
|
|
function center_x (object : in integer) return integer;
|
|
|
|
function center_y (object : in integer) return integer;
|
|
|
|
|
|
|
|
function cursor_inside (x, y, width, height : in integer) return boolean;
|
|
|
|
|
2024-04-26 18:25:29 -04:00
|
|
|
function import_sprite (file_path : in string; frames, states : in integer) return sprite;
|
|
|
|
function import_font (file_path : in string; scale, space : in integer) return font;
|
|
|
|
function import_song (file_path : in string) return song;
|
2024-05-13 09:20:16 -04:00
|
|
|
|
|
|
|
procedure import_text (data : in out string_box_data; file_path : in string);
|
2024-04-26 18:25:29 -04:00
|
|
|
|
2024-05-09 15:54:39 -04:00
|
|
|
procedure create_image (width, height : in integer);
|
|
|
|
procedure render_image (data : in sprite; x, y, u, v, width, height : in integer);
|
2024-05-23 08:03:38 -04:00
|
|
|
procedure draw_pixel (x, y : in integer; tint : in colour);
|
2024-05-09 15:54:39 -04:00
|
|
|
procedure export_image (file_path : in string);
|
2024-05-09 14:52:19 -04:00
|
|
|
|
2024-05-16 14:52:41 -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;
|
2024-05-25 06:33:05 -04:00
|
|
|
ignore : in boolean := false;
|
2024-05-16 14:52:41 -04:00
|
|
|
state : in animation := idle;
|
|
|
|
factor : in integer := zoom;
|
|
|
|
tint : in colour := (others => 255));
|
2024-04-26 18:25:29 -04:00
|
|
|
|
2024-05-19 05:42:45 -04:00
|
|
|
procedure draw_horizontally (data : in sprite; x, y, width, factor : in integer; tint : in colour := (others => 255));
|
|
|
|
procedure draw_vertically (data : in sprite; x, y, height, factor : in integer; tint : in colour := (others => 255));
|
2024-05-09 06:16:11 -04:00
|
|
|
|
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));
|
2024-04-26 18:25:29 -04:00
|
|
|
|
|
|
|
procedure play (index : in integer);
|
|
|
|
procedure stop (index : in integer);
|
2024-03-17 15:15:18 -04:00
|
|
|
|
2024-03-20 07:41:40 -04:00
|
|
|
procedure overlay;
|
|
|
|
|
2024-05-11 06:01:07 -04:00
|
|
|
function read_help_box return string;
|
2024-04-26 18:25:29 -04:00
|
|
|
function read_text_box return string;
|
|
|
|
|
2024-05-11 06:01:07 -04:00
|
|
|
procedure write_help_box (text : in string);
|
2024-04-26 18:25:29 -04:00
|
|
|
procedure write_text_box (text : in string);
|
|
|
|
|
2024-05-25 03:53:53 -04:00
|
|
|
procedure save_point (here : in core.io.file_type; data : in point);
|
|
|
|
procedure load_point (here : in core.io.file_type; data : out point);
|
2024-05-25 03:19:58 -04:00
|
|
|
|
2024-05-08 18:34:49 -04:00
|
|
|
procedure increment (value : in out integer);
|
|
|
|
procedure decrement (value : in out integer);
|
2024-05-01 00:16:19 -04:00
|
|
|
|
2024-05-09 05:07:20 -04:00
|
|
|
procedure idle_skip;
|
2024-04-30 14:20:30 -04:00
|
|
|
|
2024-05-16 14:52:41 -04:00
|
|
|
procedure toggle_fullscreen;
|
|
|
|
|
2024-05-08 18:34:49 -04:00
|
|
|
procedure initialize;
|
|
|
|
procedure deinitialize;
|
|
|
|
procedure synchronize;
|
2024-05-04 07:12:00 -04:00
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
end core;
|