diff options
author | Tom Barrett <tombarrett@siu.edu> | 2017-10-25 09:56:36 -0500 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-10-25 09:56:36 -0500 |
commit | 5c495b75f25c324b5e468d0aa80d0699bb5f3fd2 (patch) | |
tree | 0572763449f700fc407d17f185a2ce1c1495114f /src/location.rs | |
parent | 5b7a80d0e1fc0fcddbfad976a3f0fbbf7f6cd2ab (diff) |
-moved drawing to the map and out of character
-now will just compute free spaces at list level and pass to characters
Diffstat (limited to 'src/location.rs')
-rw-r--r-- | src/location.rs | 32 |
1 files changed, 32 insertions, 0 deletions
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 + } +} |