From 286be37225b5de1fb438db0a4029fd391b35c13e Mon Sep 17 00:00:00 2001 From: troido Date: Wed, 29 Jan 2020 22:53:06 +0100 Subject: players can no longer walk through walls --- src/controls.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/controls.rs') diff --git a/src/controls.rs b/src/controls.rs index 58c83b0..6ba7539 100644 --- a/src/controls.rs +++ b/src/controls.rs @@ -1,6 +1,7 @@ use serde_json::Value; +use super::components::Position; #[derive(Debug)] pub enum Direction { @@ -27,13 +28,13 @@ impl Direction { } } - pub fn to_position(&self) -> (i32, i32) { + pub fn to_position(&self) -> Position { match self { - Direction::North => (0, -1), - Direction::South => (0, 1), - Direction::East => (1, 0), - Direction::West => (-1, 0), - Direction::None => (0, 0) + Direction::North => Position::new(0, -1), + Direction::South => Position::new(0, 1), + Direction::East => Position::new(1, 0), + Direction::West => Position::new(-1, 0), + Direction::None => Position::new(0, 0) } } } -- cgit