diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-11 13:41:10 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-11 13:41:10 -0500 |
| commit | fc1ea55d97a0751e8007d496bbfe77c695982bef (patch) | |
| tree | dc378421f6e06022114f9eaa76c040855df99b4c /game | |
| parent | fix render camera positioning, other minor changes (diff) | |
| download | DungeonCrawl-fc1ea55d97a0751e8007d496bbfe77c695982bef.tar.gz DungeonCrawl-fc1ea55d97a0751e8007d496bbfe77c695982bef.tar.bz2 DungeonCrawl-fc1ea55d97a0751e8007d496bbfe77c695982bef.zip | |
graphics: refactor input key type
Diffstat (limited to 'game')
| -rw-r--r-- | game/src/main.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/game/src/main.rs b/game/src/main.rs index 6905fe3..9449710 100644 --- a/game/src/main.rs +++ b/game/src/main.rs @@ -6,7 +6,7 @@ struct Game { window: Window, dungeon: Dungeon, // to ensure the most recently-pressed direction key is used: - current_dir: Option<(Direction, KeyCode)>, + current_dir: Option<(Direction, Key)>, } impl Game { @@ -21,11 +21,11 @@ impl Game { } fn player_dir(&mut self) -> Option<Direction> { - const MOVE_KEYS: [(Direction, [KeyCode; 2]); 4] = [ - (Direction::North, [KeyCode::KEY_UP, KeyCode::KEY_W]), - (Direction::West, [KeyCode::KEY_LEFT, KeyCode::KEY_A]), - (Direction::South, [KeyCode::KEY_DOWN, KeyCode::KEY_S]), - (Direction::East, [KeyCode::KEY_RIGHT, KeyCode::KEY_D]), + const MOVE_KEYS: [(Direction, [Key; 2]); 4] = [ + (Direction::North, [Key::Up, Key::W]), + (Direction::West, [Key::Left, Key::A]), + (Direction::South, [Key::Down, Key::S]), + (Direction::East, [Key::Right, Key::D]), ]; // if a key was just pressed, use it for the new direction to move in @@ -59,7 +59,7 @@ impl Game { // Main game loop while self.window.is_open() { // Handle keyboard input - if self.window.is_key_pressed(KeyCode::KEY_F3) { + if self.window.is_key_pressed(Key::F3) { self.window.toggle_debug(); } |