Player and action...

This commit is contained in:
Ognjen Milan Robovic 2023-10-15 12:00:08 -04:00
parent b17626b8fa
commit 09ff673b61
5 changed files with 17 additions and 17 deletions

View File

@ -10,9 +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, player; with core;
use screen;
package body action is package body action is
@ -32,11 +30,6 @@ package body action is
procedure game_idle is begin null; end game_idle; procedure game_idle is begin null; end game_idle;
procedure game_exit is begin active := false; end game_exit; procedure game_exit is begin active := false; end game_exit;
procedure move_up is begin player.data.y := player.data.y - 1; end move_up;
procedure move_down is begin player.data.y := player.data.y + 1; end move_down;
procedure move_left is begin player.data.x := player.data.x - 1; end move_left;
procedure move_right is begin player.data.x := player.data.x + 1; end move_right;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
end action; end action;

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, player; with core;
package action is package action is
@ -37,10 +37,6 @@ package action is
procedure unbind (symbol : character := core.CANCEL); procedure unbind (symbol : character := core.CANCEL);
procedure game_exit; procedure game_exit;
procedure move_up;
procedure move_down;
procedure move_left;
procedure move_right;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------

View File

@ -237,10 +237,10 @@ begin
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
action.bind ('q', action.game_exit'access); action.bind ('q', action.game_exit'access);
action.bind ('w', action.move_up'access); action.bind ('w', player.move_up'access);
action.bind ('s', action.move_down'access); action.bind ('s', player.move_down'access);
action.bind ('a', action.move_left'access); action.bind ('a', player.move_left'access);
action.bind ('d', action.move_right'access); action.bind ('d', player.move_right'access);
screen.delete; screen.delete;
screen.offset; screen.offset;

View File

@ -12,6 +12,8 @@
with core, screen; with core, screen;
use screen;
package body player is package body player is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
@ -21,6 +23,11 @@ package body player is
screen.render_character ('@', core.colour.cyan, core.effect.bold, screen.height (data.y), screen.width (data.x)); screen.render_character ('@', core.colour.cyan, core.effect.bold, screen.height (data.y), screen.width (data.x));
end render; end render;
procedure move_up is begin player.data.y := player.data.y - 1; end move_up;
procedure move_down is begin player.data.y := player.data.y + 1; end move_down;
procedure move_left is begin player.data.x := player.data.x - 1; end move_left;
procedure move_right is begin player.data.x := player.data.x + 1; end move_right;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
end player; end player;

View File

@ -35,6 +35,10 @@ package player is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure render; procedure render;
procedure move_up;
procedure move_down;
procedure move_left;
procedure move_right;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------