From cbf9e47ff809b5d357e293f37ca0bf7a476ba162 Mon Sep 17 00:00:00 2001 From: Daniel Lynn Date: Sun, 18 Jul 2021 00:53:47 -0500 Subject: [PATCH] Add initial Map and Tile structs --- src/map.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/map.rs diff --git a/src/map.rs b/src/map.rs new file mode 100644 index 0000000..de927fe --- /dev/null +++ b/src/map.rs @@ -0,0 +1,25 @@ +use crate::prelude::*; + +#[derive(Clone, Copy)] +pub enum Tile { + Floor, + Wall, +} + +pub struct Map { + pub tiles: Vec, +} + +impl Map { + pub fn index(&self, x: i32, y: i32) -> usize { + ((y * MAP_HEIGHT) + x) as usize + } +} + +impl Default for Map { + fn default() -> Self { + Self { + tiles: vec![Tile::Floor; NUM_TILES], + } + } +}