diff options
| author | Yusuf Elsharawy <yusufse-2004@hotmail.com> | 2025-11-10 20:05:46 +0000 |
|---|---|---|
| committer | Yusuf Elsharawy <yusufse-2004@hotmail.com> | 2025-11-10 20:10:38 +0000 |
| commit | b1c7a57e72ab7359191249d76ec84d6cae524e2a (patch) | |
| tree | c533911f87b1641d893de5ab68ed05c2558b1cba /dungeon/src/player_input.rs | |
| parent | graphics: decouple sdl & wayland (diff) | |
| download | DungeonCrawl-b1c7a57e72ab7359191249d76ec84d6cae524e2a.tar.gz DungeonCrawl-b1c7a57e72ab7359191249d76ec84d6cae524e2a.tar.bz2 DungeonCrawl-b1c7a57e72ab7359191249d76ec84d6cae524e2a.zip | |
Refactored some code, implemented player movement
Diffstat (limited to 'dungeon/src/player_input.rs')
| -rw-r--r-- | dungeon/src/player_input.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/dungeon/src/player_input.rs b/dungeon/src/player_input.rs new file mode 100644 index 0000000..643b014 --- /dev/null +++ b/dungeon/src/player_input.rs @@ -0,0 +1,16 @@ +use crate::pos::*; + +/// Carries information on the player's inputs. +/// Allows the game to retrieve player input commands, +/// without tightly binding to a specific GUI or keybinds. +/// This way, game logic can focus on "what the inputs do" +/// as opposed to "what do the key presses mean". +#[derive(Copy, Clone, Default, Debug)] +pub struct PlayerInput { + /// The direction that the player wants to move in. + /// The creator is responsible for resolving to just one direction + /// (eg if the player is holding multiple keys at once, + /// or a joystick) + pub direction: Option<Direction>, + // other player actions are to be added later +} |