use glam::IVec2; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum Direction { Up, Down, Left, Right, } impl Direction { pub fn opposite(&self) -> Direction { match self { Direction::Up => Direction::Down, Direction::Down => Direction::Up, Direction::Left => Direction::Right, Direction::Right => Direction::Left, } } pub fn as_ivec2(&self) -> IVec2 { (*self).into() } } impl From for IVec2 { fn from(dir: Direction) -> Self { match dir { Direction::Up => -IVec2::Y, Direction::Down => IVec2::Y, Direction::Left => -IVec2::X, Direction::Right => IVec2::X, } } } pub const DIRECTIONS: [Direction; 4] = [Direction::Up, Direction::Down, Direction::Left, Direction::Right];