Another redesign, much better this time...
This commit is contained in:
parent
0ff5a3acae
commit
816189bc09
84
xabina.adb
84
xabina.adb
@ -44,17 +44,6 @@ function xabina return integer is
|
|||||||
LINE_FEED : constant character := character'val (13);
|
LINE_FEED : constant character := character'val (13);
|
||||||
ESCAPE : constant character := character'val (27);
|
ESCAPE : constant character := character'val (27);
|
||||||
|
|
||||||
function format_symbol (symbol : character := ' ';
|
|
||||||
colour : character := COLOUR_WHITE;
|
|
||||||
effect : character := EFFECT_NORMAL) return string is
|
|
||||||
format : string (1 .. 12) := escape & "[E;3CmS" & escape & "[0m";
|
|
||||||
begin
|
|
||||||
format (8) := symbol;
|
|
||||||
format (6) := colour;
|
|
||||||
format (3) := effect;
|
|
||||||
return format;
|
|
||||||
end format_symbol;
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Entity
|
-- Entity
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -518,26 +507,55 @@ function xabina return integer is
|
|||||||
-- -- Currently constant, gonna use either my xurses library or <termios.h> C bindings.
|
-- -- Currently constant, gonna use either my xurses library or <termios.h> C bindings.
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--~buffer_constant_data : string (1 .. 3 + 12 * 120 * 40 + 2 * 40);
|
type screen_width is mod 120;
|
||||||
--~buffer_constant_data : string (1 .. 3 + 12 * map_width * map_height + 2 * map_height);
|
type screen_height is mod 40;
|
||||||
--~buffer_variable_data : string (1 .. 3 + 12 * map_width * map_height + 2 * map_height);
|
|
||||||
|
|
||||||
procedure render is
|
type screen_type is array (screen_height, screen_width) of character;
|
||||||
|
|
||||||
|
screen_symbol : screen_type := (others => (others => CANCEL));
|
||||||
|
screen_colour : screen_type := (others => (others => COLOUR_WHITE));
|
||||||
|
screen_effect : screen_type := (others => (others => EFFECT_NORMAL));
|
||||||
|
|
||||||
|
procedure render_screen_delete is begin put (ESCAPE & "[2J"); end render_screen_delete;
|
||||||
|
procedure render_screen_offset is begin put (ESCAPE & "[H"); end render_screen_offset;
|
||||||
|
procedure render_cursor_hide is begin put (ESCAPE & "[?25l"); end render_cursor_hide;
|
||||||
|
procedure render_cursor_show is begin put (ESCAPE & "[?25l"); end render_cursor_show;
|
||||||
|
procedure render_realignment is begin put (CARRIAGE_RETURN & LINE_FEED); end render_realignment;
|
||||||
|
|
||||||
|
procedure render_character (symbol : character := ' ';
|
||||||
|
colour : character := COLOUR_WHITE;
|
||||||
|
effect : character := EFFECT_NORMAL) is
|
||||||
|
format : string (1 .. 12) := ESCAPE & "[E;3CmS" & ESCAPE & "[0m";
|
||||||
begin
|
begin
|
||||||
put (ESCAPE & "[H");
|
format (8) := symbol;
|
||||||
for y in map_height
|
format (6) := colour;
|
||||||
|
format (3) := effect;
|
||||||
|
put (format);
|
||||||
|
end render_character;
|
||||||
|
|
||||||
|
procedure render_screen is
|
||||||
|
begin
|
||||||
|
render_screen_offset;
|
||||||
|
for y in screen_height
|
||||||
loop
|
loop
|
||||||
for x in map_width
|
for x in screen_width
|
||||||
loop
|
loop
|
||||||
if x = player.x and y = player.y then
|
render_character (screen_symbol (y, x), screen_colour (y, x), screen_effect (y, x));
|
||||||
put (format_symbol ('@', COLOUR_CYAN, EFFECT_BOLD));
|
|
||||||
else
|
|
||||||
put (format_symbol ('.', COLOUR_GREY, EFFECT_BOLD));
|
|
||||||
end if;
|
|
||||||
end loop;
|
end loop;
|
||||||
put (CARRIAGE_RETURN & LINE_FEED);
|
render_realignment;
|
||||||
end loop;
|
end loop;
|
||||||
end render;
|
end render_screen;
|
||||||
|
|
||||||
|
procedure insert_character (symbol : character := ' ';
|
||||||
|
colour : character := COLOUR_WHITE;
|
||||||
|
effect : character := EFFECT_NORMAL;
|
||||||
|
y : screen_height := 0;
|
||||||
|
x : screen_width := 0) is
|
||||||
|
begin
|
||||||
|
screen_symbol (y, x) := symbol;
|
||||||
|
screen_colour (y, x) := colour;
|
||||||
|
screen_effect (y, x) := effect;
|
||||||
|
end insert_character;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Main
|
-- Main
|
||||||
@ -551,17 +569,27 @@ begin
|
|||||||
bind ('a', action_move_left'access);
|
bind ('a', action_move_left'access);
|
||||||
bind ('d', action_move_right'access);
|
bind ('d', action_move_right'access);
|
||||||
|
|
||||||
put (ESCAPE & "[?25l");
|
render_screen_delete;
|
||||||
|
render_screen_offset;
|
||||||
|
render_cursor_hide;
|
||||||
|
|
||||||
loop
|
loop
|
||||||
exit when active = false;
|
exit when active = false;
|
||||||
signal := CANCEL;
|
signal := CANCEL;
|
||||||
render;
|
for y in screen_height
|
||||||
|
loop
|
||||||
|
for x in screen_width
|
||||||
|
loop
|
||||||
|
insert_character ('.', COLOUR_GREY, EFFECT_BOLD, y, x);
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
insert_character ('@', COLOUR_CYAN, EFFECT_BOLD, screen_height (player.y), screen_width (player.x));
|
||||||
|
render_screen;
|
||||||
get_immediate (signal);
|
get_immediate (signal);
|
||||||
action_list (character'pos (signal)).all;
|
action_list (character'pos (signal)).all;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
put (ESCAPE & "[?25h");
|
render_cursor_show;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user