@@ -12,60 +12,60 @@ | |||
with ada.text_io; | |||
package core is | |||
package body core is | |||
------------------------------------------------------------------------------------------ | |||
procedure delete is | |||
procedure screen_delete is | |||
begin | |||
ada.text_io.put (escape & "[2J"); | |||
end delete; | |||
end screen_delete; | |||
procedure offset is | |||
procedure screen_offset is | |||
begin | |||
ada.text_io.put (escape & "[H"); | |||
end offset; | |||
end screen_offset; | |||
procedure hide_cursor is | |||
procedure screen_hide_cursor is | |||
begin | |||
ada.text_io.put (escape & "[?25l"); | |||
end hide_cursor; | |||
end screen_hide_cursor; | |||
procedure show_cursor is | |||
procedure screen_show_cursor is | |||
begin | |||
ada.text_io.put (escape & "[?25h"); | |||
end show_cursor; | |||
end screen_show_cursor; | |||
procedure new_line is | |||
procedure screen_new_line is | |||
begin | |||
ada.text_io.put (carriage_return & line_feed); | |||
end new_line; | |||
end screen_new_line; | |||
procedure render_character (symbol : character := ' '; | |||
colour : character := colour.white; | |||
effect : character := effect.normal; | |||
y : height := 0; | |||
x : width := 0) is | |||
procedure render_character (symbol : character := ' '; | |||
colour : character := '7'; | |||
effect : character := '0'; | |||
y : screen_height := 0; | |||
x : screen_width := 0) is | |||
begin | |||
symbol_matrix (y, x) := symbol; | |||
colour_matrix (y, x) := colour; | |||
effect_matrix (y, x) := effect; | |||
screen_symbol (y, x) := symbol; | |||
screen_colour (y, x) := colour; | |||
screen_effect (y, x) := effect; | |||
end render_character; | |||
procedure render_buffer is | |||
format : string (1 .. 12) := escape & "[E;3CmS" & escape & "[0m"; | |||
begin | |||
offset; | |||
for y in height | |||
screen_offset; | |||
for y in screen_height | |||
loop | |||
for x in width | |||
for x in screen_width | |||
loop | |||
format (8) := symbol_matrix (y, x); | |||
format (6) := colour_matrix (y, x); | |||
format (3) := effect_matrix (y, x); | |||
format (8) := screen_symbol (y, x); | |||
format (6) := screen_colour (y, x); | |||
format (3) := screen_effect (y, x); | |||
ada.text_io.put (format); | |||
end loop; | |||
new_line; | |||
screen_new_line; | |||
end loop; | |||
end render_buffer; | |||
@@ -12,7 +12,7 @@ | |||
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 | |||
@@ -164,19 +164,19 @@ begin | |||
action.bind ('a', player.move_left'access); | |||
action.bind ('d', player.move_right'access); | |||
screen.delete; | |||
screen.offset; | |||
screen.hide_cursor; | |||
core.screen_delete; | |||
core.screen_offset; | |||
core.screen_hide_cursor; | |||
generate_map; | |||
map.generate; | |||
------------------------------------------------------------------------------------------ | |||
loop | |||
action.signal := core.cancel; | |||
render_map; | |||
map.render; | |||
player.render; | |||
screen.render_buffer; | |||
core.render_buffer; | |||
ada.text_io.get_immediate (action.signal); | |||
action.list (character'pos (action.signal)).all; | |||
exit when action.active = false; | |||
@@ -184,7 +184,7 @@ begin | |||
------------------------------------------------------------------------------------------ | |||
screen.show_cursor; | |||
core.screen_show_cursor; | |||
return 0; | |||
@@ -10,7 +10,7 @@ | |||
-- 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 | |||
@@ -22,7 +22,7 @@ package body map is | |||
loop | |||
for x in width | |||
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 generate; | |||
@@ -32,14 +32,14 @@ package body map is | |||
colour : character := core.colour.white; | |||
effect : character := core.effect.normal; | |||
begin | |||
for y in screen.height | |||
for y in core.screen_height | |||
loop | |||
for x in screen.width | |||
for x in core.screen_width | |||
loop | |||
symbol := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).symbol; | |||
colour := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).colour; | |||
effect := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).effect; | |||
screen.render_character (symbol, colour, effect, y, x); | |||
symbol := constant_data (matrical_data (height (y), width (x)).map).symbol; | |||
colour := constant_data (matrical_data (height (y), width (x)).map).colour; | |||
effect := constant_data (matrical_data (height (y), width (x)).map).effect; | |||
core.render_character (symbol, colour, effect, y, x); | |||
end loop; | |||
end loop; | |||
end render; | |||
@@ -10,17 +10,18 @@ | |||
-- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now... | |||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |||
with core, screen; | |||
use screen; | |||
with core; | |||
package body player is | |||
------------------------------------------------------------------------------------------ | |||
use type core.screen_width; | |||
use type core.screen_height; | |||
procedure render is | |||
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; | |||
procedure move_up is | |||