a bit more collision detection logic

This commit is contained in:
2026-03-08 19:06:34 -05:00
parent 23b7e1ad23
commit 6cbf4c9328
7 changed files with 178 additions and 3 deletions
+30
View File
@@ -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;
}
}
+1
View File
@@ -0,0 +1 @@
pub mod field;