a bit more collision detection logic
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub enum Tile {
|
||||
Empty,
|
||||
Wall,
|
||||
Food,
|
||||
}
|
||||
|
||||
pub struct Field {
|
||||
pub width: usize,
|
||||
pub height: usize,
|
||||
pub tiles: Vec<Tile>,
|
||||
}
|
||||
|
||||
impl Field {
|
||||
pub fn new(width: usize, height: usize) -> Self {
|
||||
Self {
|
||||
width,
|
||||
height,
|
||||
tiles: vec![Tile::Empty; width * height],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_tile(&self, x: usize, y: usize) -> Tile {
|
||||
self.tiles[y * self.width + x]
|
||||
}
|
||||
|
||||
pub fn set_tile(&mut self, x: usize, y: usize, tile: Tile) {
|
||||
self.tiles[y * self.width + x] = tile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod field;
|
||||
Reference in New Issue
Block a user