Added line drawing function and refactored squared grid.

This commit is contained in:
Ognjen Milan Robovic 2024-02-19 14:21:24 -05:00
parent fbb99ad4aa
commit c05eafca94
2 changed files with 22 additions and 8 deletions

View File

@ -115,6 +115,13 @@ package body core is
------------------------------------------------------------------------------------------
procedure line (origin, offset : in vector_2) is
begin
render_vector (origin.x, origin.y, origin.x + offset.x, origin.y + offset.y);
end line;
------------------------------------------------------------------------------------------
procedure write (text : in string; x, y : in integer; colour : in integer := 16#CCCCCC#) is
begin
render_string (c_string (text), x, y, colour, false);
@ -203,7 +210,8 @@ package body core is
begin
for vertical in 0 .. line_v2
loop
render_vector (offset_x + vertical * base, y, offset_x + vertical * base, y + crop_height);
--~render_vector (offset_x + vertical * base, y, offset_x + vertical * base, y + crop_height);
line ((offset_x + vertical * base, y), (0, crop_height));
end loop;
--
--~while horizontal < y + height - base - offset
@ -224,13 +232,15 @@ package body core is
--~end loop;
for horizontal in 0 .. line_h
loop
render_vector (x, offset_y + horizontal * base, x + width, offset_y + horizontal * base);
--~render_vector (x, offset_y + horizontal * base, x + width, offset_y + horizontal * base);
line ((x, offset_y + horizontal * base), (width, 0));
--
for vertical in 0 .. line_v1
loop
full_vector := y + 2 * base * (horizontal / 2) - ((y + height) mod base) / 2;
--
render_vector (offset_x + vertical * base - base / 2, full_vector + base, offset_x + vertical * base - base / 2, full_vector + 2 * base);
--~render_vector (offset_x + vertical * base - base / 2, full_vector + base, offset_x + vertical * base - base / 2, full_vector + 2 * base);
line ((offset_x + vertical * base - base / 2, full_vector + base), (0, base));
end loop;
--
if horizontal > 1 then
@ -238,7 +248,8 @@ package body core is
loop
full_vector := y + 2 * base * (horizontal / 2) - ((y + height) mod base) / 2;
--
render_vector (offset_x + vertical * base, full_vector, offset_x + vertical * base, full_vector + base);
--~render_vector (offset_x + vertical * base, full_vector, offset_x + vertical * base, full_vector + base);
line ((offset_x + vertical * base, full_vector), (0, base));
end loop;
end if;
end loop;
@ -247,7 +258,8 @@ package body core is
loop
full_vector := y + 2 * base * ((height / base) / 2) - ((y + height) mod base) / 2;
--
render_vector (offset_x + vertical * base, full_vector, offset_x + vertical * base, full_vector + crop_height);
--~render_vector (offset_x + vertical * base, full_vector, offset_x + vertical * base, full_vector + crop_height);
line ((offset_x + vertical * base, full_vector), (0, crop_height));
end loop;
end draw_squared_grid;

View File

@ -103,6 +103,8 @@ package core is
procedure draw (data : in sprite; x, y : in integer);
procedure move (data : in sprite; x, y, frame, state : in integer);
procedure line (origin, offset : in vector_2);
procedure write (text : in string; x, y : in integer; colour : in integer := 16#CCCCCC#);
procedure hexagonal_grid (x, y, width, height : in integer; fill : in boolean);