From 09ff673b61fd33e2586348ad34fc0a10a69efba6 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 15 Oct 2023 12:00:08 -0400 Subject: [PATCH] Player and action... --- action.adb | 9 +-------- action.ads | 6 +----- main.adb | 8 ++++---- player.adb | 7 +++++++ player.ads | 4 ++++ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/action.adb b/action.adb index 0852e02..ccd4217 100644 --- a/action.adb +++ b/action.adb @@ -10,9 +10,7 @@ -- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now... ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -with core, screen, player; - -use screen; +with core; package body action is @@ -32,11 +30,6 @@ package body action is procedure game_idle is begin null; end game_idle; 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; diff --git a/action.ads b/action.ads index 99b1fe1..d83988e 100644 --- a/action.ads +++ b/action.ads @@ -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, player; +with core; package action is @@ -37,10 +37,6 @@ package action is procedure unbind (symbol : character := core.CANCEL); procedure game_exit; - procedure move_up; - procedure move_down; - procedure move_left; - procedure move_right; ------------------------------------------------------------------------------------------ diff --git a/main.adb b/main.adb index 451ad24..b8958d9 100644 --- a/main.adb +++ b/main.adb @@ -237,10 +237,10 @@ begin ------------------------------------------------------------------------------------------ action.bind ('q', action.game_exit'access); - action.bind ('w', action.move_up'access); - action.bind ('s', action.move_down'access); - action.bind ('a', action.move_left'access); - action.bind ('d', action.move_right'access); + action.bind ('w', player.move_up'access); + action.bind ('s', player.move_down'access); + action.bind ('a', player.move_left'access); + action.bind ('d', player.move_right'access); screen.delete; screen.offset; diff --git a/player.adb b/player.adb index 0895eae..5ed73db 100644 --- a/player.adb +++ b/player.adb @@ -12,6 +12,8 @@ with core, screen; +use screen; + 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)); 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; diff --git a/player.ads b/player.ads index fac41ca..1427404 100644 --- a/player.ads +++ b/player.ads @@ -35,6 +35,10 @@ package player is ------------------------------------------------------------------------------------------ procedure render; + procedure move_up; + procedure move_down; + procedure move_left; + procedure move_right; ------------------------------------------------------------------------------------------