From e50c26356ea2177200efa255003261e7616ee6bd Mon Sep 17 00:00:00 2001 From: klangner Date: Mon, 28 Jun 2021 17:11:51 +0200 Subject: [PATCH] Added index to the Tile --- src/map.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/map.rs b/src/map.rs index 27f6eed..83fe9f4 100644 --- a/src/map.rs +++ b/src/map.rs @@ -14,6 +14,7 @@ use super::geometry::{Point, Rect, usize_abs}; #[derive(PartialEq, Copy, Clone, Debug, Eq, Hash)] pub struct Tile { is_blocked: bool, + index: usize, } #[derive(PartialEq, Copy, Clone)] @@ -33,12 +34,16 @@ pub struct Map { } impl Tile { + pub fn new(is_blocked: bool, index: usize) -> Tile { + Tile { is_blocked, index} + } + pub fn wall() -> Tile { - Tile { is_blocked: true } + Tile::new(true, 0) } pub fn floor() -> Tile { - Tile { is_blocked: false } + Tile::new(false, 0) } pub fn is_walkable(&self) -> bool {