diff --git a/assets/tiles/marble.png b/assets/tiles/marble.png index 1f24d7e..3387000 100644 Binary files a/assets/tiles/marble.png and b/assets/tiles/marble.png differ diff --git a/src/marble_engine.rs b/src/marble_engine.rs index 7cf90e4..e49afe0 100644 --- a/src/marble_engine.rs +++ b/src/marble_engine.rs @@ -70,14 +70,27 @@ impl Machine { if let Some(tile) = self.board.get((x, y).into()) { let px = x as i32 * tile_size + offset.x as i32 + tile_size / 2; let py = y as i32 * tile_size + offset.y as i32 + tile_size / 2; - if let Tile::Marble { value, dir: _ } = tile { + if let Tile::Marble { value, dir } = tile { + let fontsize = (zoom + 1) * 10; d.draw_text( &format!("{value}"), px - tile_size / 2 + 2, py - tile_size / 2 + 2, - 20, + fontsize, Color::MAGENTA, - ) + ); + d.draw_text( + match dir { + Direction::Up => "^", + Direction::Down => "v", + Direction::Left => "<", + Direction::Right => ">", + }, + px - tile_size / 2 + 2, + py - tile_size / 2 + fontsize, + fontsize, + Color::MAGENTA, + ); } } } @@ -114,9 +127,7 @@ impl Machine { new_tile = Some(Tile::Blank); } Tile::Digit(d) => { - let new_val = value - .wrapping_mul(10) - .wrapping_add(*d as MarbleValue); + let new_val = value.wrapping_mul(10).wrapping_add(*d as MarbleValue); *target = Tile::Marble { value: new_val, dir, @@ -258,7 +269,7 @@ impl Machine { || !self.board.get_or_blank(pos_b).is_blank()) && self.board.get_or_blank(front_pos).is_blank() { - let result = match op { + let value = match op { MathOp::Add => val_a.wrapping_add(val_b), MathOp::Sub => val_a.wrapping_sub(val_b), MathOp::Mul => val_a.wrapping_mul(val_b), @@ -266,7 +277,7 @@ impl Machine { MathOp::Rem => val_a.checked_rem(val_b).unwrap_or_default(), }; // println!("{op:?} a:{val_a} b:{val_b}"); - *self.board.get_mut_unchecked(front_pos) = Tile::Marble { value: result, dir }; + *self.board.get_mut_unchecked(front_pos) = Tile::Marble { value, dir }; self.marbles.push(front_pos); } } @@ -314,4 +325,3 @@ impl Machine { } } } -