From 1c3ec15a9a8b7cef3c544af225d028b3de13d75e Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Thu, 2 Nov 2017 08:36:26 -0500 Subject: - added color constants, fixed some syntax, and changed method of getting potential locations --- src/location.rs | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'src/location.rs') diff --git a/src/location.rs b/src/location.rs index 4a98ef6..eb8110c 100644 --- a/src/location.rs +++ b/src/location.rs @@ -24,28 +24,17 @@ impl cmp::PartialEq for Location { } impl Location { - pub fn up(self) -> Location { - Location{ x : self.x, y : self.y + 1 } - } - pub fn upleft(self) -> Location { - Location{ x : self.x - 1, y : self.y + 1 } - } - pub fn upright(self) -> Location { - Location{ x : self.x + 1, y : self.y + 1 } - } - pub fn down(self) -> Location { - Location{ x : self.x, y : self.y - 1 } - } - pub fn downleft(self) -> Location { - Location{ x : self.x - 1, y : self.y - 1 } - } - pub fn downright(self) -> Location { - Location{ x : self.x + 1, y : self.y - 1 } - } - pub fn right(self) -> Location { - Location{ x : self.x + 1, y : self.y } - } - pub fn left(self) -> Location { - Location{ x : self.x - 1, y : self.y } + pub fn get_around(self) -> Vec { + let mut around = Vec::new(); + around.push(Location { x : self.x, y : self.y }); + around.push(Location { x : self.x+1, y : self.y }); + around.push(Location { x : self.x-1, y : self.y }); + around.push(Location { x : self.x, y : self.y+1 }); + around.push(Location { x : self.x, y : self.y-1 }); + around.push(Location { x : self.x+1, y : self.y+1 }); + around.push(Location { x : self.x-1, y : self.y-1 }); + around.push(Location { x : self.x+1, y : self.y-1 }); + around.push(Location { x : self.x-1, y : self.y+1 }); + around } } -- cgit v1.2.3