#[derive(PartialEq, Debug)] pub struct Position { level: usize, x: usize, y: usize, } impl Position { pub fn new(level: usize, x: usize, y: usize) -> Self { Self { level, x, y, } } pub fn change(&mut self, dx: i16, dy: i16) { self.x = ((self.x as i16) + dx) as usize; self.y = ((self.y as i16) + dy) as usize; } pub fn set(&mut self, level: usize, x: usize, y: usize) { self.level = level; self.x = x; self.y = y; } pub fn get_level(&self) -> usize { self.level } pub fn get_x(&self) -> usize { self.x } pub fn get_y(&self) -> usize { self.y } }