Making stuff less bad I hope...

This commit is contained in:
Ognjen Milan Robovic 2023-10-15 12:35:38 -04:00
parent 73a56f8f38
commit 83e04221d9
4 changed files with 47 additions and 46 deletions

View File

@ -12,60 +12,60 @@
with ada.text_io; with ada.text_io;
package core is package body core is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure delete is procedure screen_delete is
begin begin
ada.text_io.put (escape & "[2J"); ada.text_io.put (escape & "[2J");
end delete; end screen_delete;
procedure offset is procedure screen_offset is
begin begin
ada.text_io.put (escape & "[H"); ada.text_io.put (escape & "[H");
end offset; end screen_offset;
procedure hide_cursor is procedure screen_hide_cursor is
begin begin
ada.text_io.put (escape & "[?25l"); ada.text_io.put (escape & "[?25l");
end hide_cursor; end screen_hide_cursor;
procedure show_cursor is procedure screen_show_cursor is
begin begin
ada.text_io.put (escape & "[?25h"); ada.text_io.put (escape & "[?25h");
end show_cursor; end screen_show_cursor;
procedure new_line is procedure screen_new_line is
begin begin
ada.text_io.put (carriage_return & line_feed); ada.text_io.put (carriage_return & line_feed);
end new_line; end screen_new_line;
procedure render_character (symbol : character := ' '; procedure render_character (symbol : character := ' ';
colour : character := colour.white; colour : character := '7';
effect : character := effect.normal; effect : character := '0';
y : height := 0; y : screen_height := 0;
x : width := 0) is x : screen_width := 0) is
begin begin
symbol_matrix (y, x) := symbol; screen_symbol (y, x) := symbol;
colour_matrix (y, x) := colour; screen_colour (y, x) := colour;
effect_matrix (y, x) := effect; screen_effect (y, x) := effect;
end render_character; end render_character;
procedure render_buffer is procedure render_buffer is
format : string (1 .. 12) := escape & "[E;3CmS" & escape & "[0m"; format : string (1 .. 12) := escape & "[E;3CmS" & escape & "[0m";
begin begin
offset; screen_offset;
for y in height for y in screen_height
loop loop
for x in width for x in screen_width
loop loop
format (8) := symbol_matrix (y, x); format (8) := screen_symbol (y, x);
format (6) := colour_matrix (y, x); format (6) := screen_colour (y, x);
format (3) := effect_matrix (y, x); format (3) := screen_effect (y, x);
ada.text_io.put (format); ada.text_io.put (format);
end loop; end loop;
new_line; screen_new_line;
end loop; end loop;
end render_buffer; end render_buffer;

View File

@ -12,7 +12,7 @@
with ada.text_io; with ada.text_io;
with core, action, screen, map, item, magic, ammunition, weapon, armour, plant, animal, monster, player; with core, action, map, item, magic, ammunition, weapon, armour, plant, animal, monster, player;
function main return integer is function main return integer is
@ -164,19 +164,19 @@ begin
action.bind ('a', player.move_left'access); action.bind ('a', player.move_left'access);
action.bind ('d', player.move_right'access); action.bind ('d', player.move_right'access);
screen.delete; core.screen_delete;
screen.offset; core.screen_offset;
screen.hide_cursor; core.screen_hide_cursor;
generate_map; map.generate;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
loop loop
action.signal := core.cancel; action.signal := core.cancel;
render_map; map.render;
player.render; player.render;
screen.render_buffer; core.render_buffer;
ada.text_io.get_immediate (action.signal); ada.text_io.get_immediate (action.signal);
action.list (character'pos (action.signal)).all; action.list (character'pos (action.signal)).all;
exit when action.active = false; exit when action.active = false;
@ -184,7 +184,7 @@ begin
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
screen.show_cursor; core.screen_show_cursor;
return 0; return 0;

16
map.adb
View File

@ -10,7 +10,7 @@
-- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now... -- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
with core, screen; with core;
package body map is package body map is
@ -22,7 +22,7 @@ package body map is
loop loop
for x in width for x in width
loop loop
map_matrical_data (y, x) := (MAP_WOODEN_FLOOR, map_constant_data (MAP_WOODEN_FLOOR).condition_limit); matrical_data (y, x) := (MAP_WOODEN_FLOOR, constant_data (MAP_WOODEN_FLOOR).condition_limit);
end loop; end loop;
end loop; end loop;
end generate; end generate;
@ -32,14 +32,14 @@ package body map is
colour : character := core.colour.white; colour : character := core.colour.white;
effect : character := core.effect.normal; effect : character := core.effect.normal;
begin begin
for y in screen.height for y in core.screen_height
loop loop
for x in screen.width for x in core.screen_width
loop loop
symbol := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).symbol; symbol := constant_data (matrical_data (height (y), width (x)).map).symbol;
colour := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).colour; colour := constant_data (matrical_data (height (y), width (x)).map).colour;
effect := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).effect; effect := constant_data (matrical_data (height (y), width (x)).map).effect;
screen.render_character (symbol, colour, effect, y, x); core.render_character (symbol, colour, effect, y, x);
end loop; end loop;
end loop; end loop;
end render; end render;

View File

@ -10,17 +10,18 @@
-- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now... -- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
with core, screen; with core;
use screen;
package body player is package body player is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
use type core.screen_width;
use type core.screen_height;
procedure render is procedure render is
begin begin
screen.render_character ('@', core.colour.cyan, core.effect.bold, screen.height (data.y), screen.width (data.x)); core.render_character ('@', core.colour.cyan, core.effect.bold, core.screen_height (data.y), core.screen_width (data.x));
end render; end render;
procedure move_up is procedure move_up is