Add initial Map and Tile structs

This commit is contained in:
Daniel Lynn 2021-07-18 00:53:47 -05:00
parent 7b56c52fff
commit cbf9e47ff8
Signed by: daniel
GPG Key ID: 28496A140E180A9D

25
src/map.rs Normal file
View File

@ -0,0 +1,25 @@
use crate::prelude::*;
#[derive(Clone, Copy)]
pub enum Tile {
Floor,
Wall,
}
pub struct Map {
pub tiles: Vec<Tile>,
}
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],
}
}
}