add digit tool
This commit is contained in:
parent
465b5c40d1
commit
fc6c66ff31
5 changed files with 130 additions and 65 deletions
|
@ -9,6 +9,15 @@ pub struct Pos {
|
|||
pub y: isize,
|
||||
}
|
||||
|
||||
impl Pos {
|
||||
pub const fn to_vec(&self) -> Vector2 {
|
||||
Vector2 {
|
||||
x: self.x as f32,
|
||||
y: self.y as f32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(usize, usize)> for Pos {
|
||||
fn from(value: (usize, usize)) -> Self {
|
||||
Self {
|
||||
|
@ -91,7 +100,15 @@ impl Board {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_mut(&mut self, p: Pos) -> &mut Tile {
|
||||
pub fn get_mut(&mut self, p: Pos) -> Option<&mut Tile> {
|
||||
if self.in_bounds(p) {
|
||||
Some(&mut self.rows[p.y as usize][p.x as usize])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_mut_unchecked(&mut self, p: Pos) -> &mut Tile {
|
||||
if self.in_bounds(p) {
|
||||
&mut self.rows[p.y as usize][p.x as usize]
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue