Add initial Map and Tile structs
This commit is contained in:
parent
7b56c52fff
commit
cbf9e47ff8
25
src/map.rs
Normal file
25
src/map.rs
Normal 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],
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user