From 5c495b75f25c324b5e468d0aa80d0699bb5f3fd2 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Wed, 25 Oct 2017 09:56:36 -0500 Subject: -moved drawing to the map and out of character -now will just compute free spaces at list level and pass to characters --- src/location.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/location.rs') diff --git a/src/location.rs b/src/location.rs index b1b9144..f17965e 100644 --- a/src/location.rs +++ b/src/location.rs @@ -1,3 +1,5 @@ +use std::cmp; + pub struct Location{ pub x : i32, pub y : i32 @@ -9,3 +11,33 @@ impl Clone for Location { *self } } + +impl cmp::PartialEq for Location { + fn eq(&self, rhs : &Location) -> bool { + if self.x == rhs.x && self.y == rhs.y { + true + } + else { + false + } + } +} + +impl Location { + pub fn up(mut self) -> Location { + self.y += 1; + self + } + pub fn down(mut self) -> Location { + self.y -= 1; + self + } + pub fn right(mut self) -> Location { + self.x += 1; + self + } + pub fn left(mut self) -> Location { + self.x -= 1; + self + } +} -- cgit v1.2.3