use crate::prelude::*; #[derive(Clone, Copy, Debug)] pub struct Block { pos: Position, dir: Direction, size: Position, } impl Block { pub fn new(size: Position) -> Self { Self { pos: Position::new(0, 0), dir: Direction::Up, size, } } pub fn get_aabb(&self) -> AABB { let npos = match self.dir { Direction::Up => self.pos, Direction::Right => self.pos.in_direction(&Direction::Left, self.size.y - 1), Direction::Down => self.pos - (self.size - Position::new(1, 1)), Direction::Left => self.pos.in_direction(&Direction::Up, self.size.x - 1), }; let nsize = match self.dir { Direction::Up | Direction::Down => self.size, Direction::Right | Direction::Left => Position { x: self.size.y, y: self.size.x, }, }; AABB::new(npos, npos + nsize - Position::new(1, 1)) } }