From 682dff48f92e70616e892a473d1cec425c0bab03 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sat, 5 Oct 2024 20:48:05 +0200 Subject: [PATCH] draw marble direction --- assets/tiles/marble.png | Bin 183 -> 176 bytes src/marble_engine.rs | 28 +++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/assets/tiles/marble.png b/assets/tiles/marble.png index 1f24d7eed4cb4e6dfe45198a43fae399a3ae2716..338700059cae790a62f443c04807c5801051a593 100644 GIT binary patch delta 148 zcmV;F0BirZ0k8p(B!72FL_t(IjbmV-5HRAB;4Z)ZADREPQxmIN3_)a#SsDoOX*aMN zgu+3$6_-KChQJxPG-ERe*$^f|nvem^8_0l>Slh9IubrBVB)I?^7idz7Kuj$r_@A;f6LY5*>SaAhWn0RRXtE)*BBhz-900000 z8Q_cs "^", + 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 { } } } -