Core system and file path changes...

This commit is contained in:
Ognjen Milan Robovic 2024-02-16 05:52:11 -05:00
parent 4d966c8093
commit 2a43c01f4c
9 changed files with 50 additions and 94 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
source/*.o
source/*.ali
xhads
sprite/*

View File

@ -6,6 +6,29 @@ package body core is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
procedure configure is
begin
engine_configure;
--
hexagon_grid_sprite := load_sprite ("sprite/menu/hexagon_grid_tile.png", 1, 1);
hexagon_fill_sprite := load_sprite ("sprite/menu/hexagon_fill_tile.png", 1, 1);
end configure;
------------------------------------------------------------------------------------------
procedure synchronize is
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);
--
engine_synchronize;
end synchronize;
------------------------------------------------------------------------------------------
function flip_coin return integer is
begin
return (random_integer (0, 1));
@ -87,44 +110,23 @@ package body core is
crop_width : constant integer := width mod hexagon_grid_sprite.width;
crop_height : constant integer := height mod hexagon_grid_sprite.height;
use_sprite : constant sprite := (if fill then hexagon_fill_sprite else hexagon_grid_sprite);
--~u, v : integer;
begin
for move_y in 0 .. height / hexagon_grid_sprite.height - 1
loop
for move_x in 0 .. width / hexagon_grid_sprite.width - 1
loop
--~u := hexagon_grid_sprite.width * codex'pos (map.terrain) * 4;
--~v := hexagon_grid_sprite.height * map.block (move_x, move_y);
--
draw (use_sprite, x + move_x * hexagon_grid_sprite.width, y + move_y * hexagon_grid_sprite.height);
end loop;
--
--~u := 0;
--~v := hexagon_grid_sprite.height * map.block (width / hexagon_grid_sprite.width, move_y);
--
crop (use_sprite, x + width - crop_width, y + move_y * hexagon_grid_sprite.height, 0, 0, crop_width, hexagon_grid_sprite.height);
end loop;
--
for move_x in 0 .. width / hexagon_grid_sprite.width - 1
loop
--~u := 0;
--~v := hexagon_grid_sprite.height * map.block (move_x, height / hexagon_grid_sprite.height);
--
crop (use_sprite, x + move_x * hexagon_grid_sprite.width, y + height - crop_height, 0, 0, hexagon_grid_sprite.width, crop_height);
end loop;
--
--~u := 0;
--~v := hexagon_grid_sprite.height * map.block (width / hexagon_grid_sprite.width, height / hexagon_grid_sprite.height);
--
crop (use_sprite, x + width - crop_width, y + height - crop_height, 0, 0, crop_width, crop_height);
--~begin
--~for y in 0 .. window_height / 48
--~loop
--~for x in 0 .. window_width / 32
--~loop
--~draw ((if fill then hexagon_fill_sprite else hexagon_grid_sprite), x * hexagon_grid_sprite.width, y * hexagon_grid_sprite.height);
--~end loop;
--~end loop;
end hexagonal_grid;
------------------------------------------------------------------------------------------

View File

@ -84,6 +84,9 @@ package core is
------------------------------------------------------------------------------------------
procedure configure;
procedure synchronize;
function flip_coin return integer;
function roll_dice return integer;
function by_chance (chance : in integer) return integer;

View File

@ -18,13 +18,12 @@ package body item is
begin
for index in codex
loop
--~declare
--~folder : constant string := core.lowercase (school'image (trait (index).kind));
--~file : constant string := core.lowercase (codex'image (index));
--~begin
--~icon (index) := core.load_sprite ("sprite/ui/item/" & folder & "/" & file & ".png", 1, 1);
--~end;
sprite (index) := core.load_sprite ("sprite/item/" & core.lowercase (codex'image (index)) & ".png", 1, 1);
declare
folder : constant string := core.lowercase (slot'image (trait (index).kind));
file : constant string := core.lowercase (codex'image (index));
begin
sprite (index) := core.load_sprite ("sprite/item/" & folder & "/" & file & ".png", 1, 1);
end;
end loop;
end configure;

View File

@ -176,10 +176,10 @@ package item is
("Titan's Cuirass ", chest, 3, effect.none),
("Titan's Gladius ", main_hand, 3, effect.none),
("Titan's Thunder ", main_hand, 3, effect.none),
("Tome of Air ", bag, 3, effect.none),
("Tome of Earth ", bag, 3, effect.none),
("Tome of Fire ", bag, 3, effect.none),
("Tome of Water ", bag, 3, effect.none),
("Tome of Air ", off_hand, 3, effect.none),
("Tome of Earth ", off_hand, 3, effect.none),
("Tome of Fire ", off_hand, 3, effect.none),
("Tome of Water ", off_hand, 3, effect.none),
("Torso of Legion ", bag, 3, effect.none),
("Cyclop's Tunic ", chest, 3, effect.none),
("Vampire's Cowl ", full_body, 3, effect.none),

View File

@ -1,4 +1,4 @@
with core, ui, menu, effect, magic;
with core, effect, magic;
use magic;
@ -30,10 +30,8 @@ package body magic is
------------------------------------------------------------------------------------------
procedure draw (index : in codex; x, y : in integer) is
offset : constant integer := 16;
begin
ui.draw_frame (x, y, icon (index).width + offset, icon (index).height + offset);
core.draw (icon (index), x + offset / 2, y + offset / 2);
core.draw (icon (index), x, y);
end draw;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -21,17 +21,7 @@ procedure main is
begin
core.engine_configure;
core.hexagon_grid_sprite := core.load_sprite ("sprite/menu/hexagon_grid_tile.png", 1, 1);
core.hexagon_fill_sprite := core.load_sprite ("sprite/menu/hexagon_fill_tile.png", 1, 1);
--~attribute.sprite := core.load_sprite ("sprite/ui/attribute.png", 1, 1);
--~skill.sprite := core.load_sprite ("sprite/ui/skill.png", 1, 1);
--~resource.sprite := core.load_sprite ("sprite/ui/resource.png", 1, 1);
--~magic.sprite := core.load_sprite ("sprite/ui/magic.png", 1, 1);
--~item.sprite := core.load_sprite ("sprite/ui/item.png", 1, 1);
core.configure;
ui.configure;
might.configure;
magic.configure;
@ -47,29 +37,20 @@ begin
gameplay: loop
exit when core.engine_active = false;
--
core.global_time := core.global_time + 1;
--
core.global_time := core.global_time mod (core.gameplay_framerate * core.animation_framerate);
core.gameplay_time := core.global_time mod (core.gameplay_framerate);
core.animation_time := core.global_time / (core.gameplay_framerate / core.animation_framerate);
--
delay duration (1.0 / 60.0);
--
core.engine_synchronize;
core.synchronize;
--
--~if core.cursor_mode = 1 then
--~world_active := world.codex'val ((world.codex'pos (world_active) + 1) mod 6);
--~delay duration (0.333);
--~end if;
--~world.render (world_active, 0, 0);
--
world.draw (24, 24, core.window_width - 480 - 48, core.window_height - 48, core.cursor_mode = 2);
--
ui.active := ui.steam;
if core.signal_mode = core.signal_code'pos (core.signal_left) then core.camera.x := core.camera.x - 1; end if;
if core.signal_mode = core.signal_code'pos (core.signal_right) then core.camera.x := core.camera.x + 1; end if;
if core.signal_mode = core.signal_code'pos (core.signal_up) then core.camera.y := core.camera.y - 1; end if;
if core.signal_mode = core.signal_code'pos (core.signal_down) then core.camera.y := core.camera.y + 1; end if;
ui.active := ui.steam;
if core.cursor_mode = 3 then
--~ui.active := ui.style'val (ui.style'pos (ui.active) mod 4);
--~case ui.active is
@ -86,17 +67,6 @@ begin
--~might.draw (this, 112 * (might.codex'pos (this) / 7) + 64, 112 * (might.codex'pos (this) mod 7) + 64);
--~end loop;
--
--~unit.render (unit.angel, unit.attack, 300, 300);
--~unit.render (unit.arch_angel, unit.moving, 600, 300);
--
--~for this in unit.goblin .. unit.ancient_behemoth
--~loop
--~for anim in unit.animation
--~loop
--~unit.draw (this, anim, 80 * (unit.codex'pos (this) mod 14) + 40, 64 * unit.animation'pos (anim) + 40);
--~end loop;
--~end loop;
--
--~for this in unit.pikeman .. unit.ghost_dragon
--~loop
--~unit.render (this, unit.idle, 96 * (unit.codex'pos (this) / 7) + 32, 96 * (unit.codex'pos (this) mod 7) + 32);
@ -107,17 +77,6 @@ begin
--~construction.draw (this, 128 * (construction.codex'pos (this) mod 12) + 32, 128 * (construction.codex'pos (this) / 12) + 32);
--~end loop;
--
--~attribute.render (attribute.defense, 0, 100);
--~skill.render (skill.archery, 1, 100, 100);
--~skill.render (skill.tactics, 2, 200, 100);
--~skill.render (skill.fire_magic, 3, 300, 100);
--~resource.render (resource.mercury, 400, 100);
--
--~core.animate_sprite (test, 700, 100, (64, 64, 0, 0), 10);
--
--~menu.render (menu.attribute_list, 1200, 400, 0, 0);
--~menu.render (menu.skill_list, 400, 400, 0, 0);
--
ui.draw_menu (0, 0, core.window_width - 480, core.window_height, false);
ui.draw_tiny_menu (core.window_width - 480, 0, 480, core.window_height, true);
--
@ -137,14 +96,9 @@ begin
core.render_string (core.c_string ("M :" & core.signal_code'image (core.signal_code'val (core.signal_mode))), 1352, 128, 16#CCCCCC#, false);
core.render_string (core.c_string ("U :" & integer'image (core.camera.x)), 1352, 160, 16#CCCCCC#, false);
core.render_string (core.c_string ("V :" & integer'image (core.camera.y)), 1352, 192, 16#CCCCCC#, false);
--
--~ui.draw_tiny_menu (400, 400, 400, 400, true);
--~menu.draw_menu (200, 100, 400, 200, true);
--~menu.draw_tiny_menu (800, 200, 400, 200, true);
--
--~menu.draw_background (menu.main_background, 96, 96, 288, 128);
--~menu.draw_background (menu.main_background, 96, 300, 200, 100);
--~menu.draw_background (menu.main_background, 96, 450, 96, 96);
core.render_string (core.c_string ("t :" & integer'image (core.global_time)), 1352, 224, 16#CCCCCC#, false);
core.render_string (core.c_string ("g :" & integer'image (core.gameplay_time)), 1352, 256, 16#CCCCCC#, false);
core.render_string (core.c_string ("a :" & integer'image (core.animation_time)), 1352, 288, 16#CCCCCC#, false);
end loop gameplay;
end main;

View File

@ -7,8 +7,8 @@ default:
gnatmake -O3 -fstack-check -c main.adb
gnatbind main.ali
gcc -g -ansi -Wall -Wextra -Wpedantic -Ofast -fstack-check -c -fPIC -o raylib.o raylib.c
gnatlink main.ali system.o raylib.o ai.o -o mam_raylib -lraylib -lc -lgfortran
mv mam_raylib ../mam_raylib
gnatlink main.ali system.o raylib.o ai.o -o xhads -lraylib -lc -lgfortran
mv xhads ../xhads
#
#~ gnatmake -O3 -fstack-check -c main.adb
#~ gnatbind main.ali

View File

@ -1,4 +1,4 @@
with core, ui, menu, effect, might;
with core, effect, might;
use might;
@ -30,10 +30,8 @@ package body might is
------------------------------------------------------------------------------------------
procedure draw (value : in codex; x, y : in integer) is
offset : constant integer := 16;
begin
ui.draw_frame (x, y, icon (value).width + offset, icon (value).height + offset);
core.draw (icon (value), x + offset / 2, y + offset / 2);
core.draw (icon (value), x, y);
end draw;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------