Skip to content

Commit

Permalink
fixed undo
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartonrealista committed Jul 5, 2024
1 parent c119e0f commit 0e0e307
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ impl Application for YourApp {
Message::StartPressed => {
self.game.menu.width = self.game.menu.width_inptut.parse().unwrap();
self.game.menu.height = self.game.menu.height_inptut.parse().unwrap();

self.game.board = Board::new(self.game.menu.width, self.game.menu.height);
self.game.old_board = self.game.board.clone();
self.game.menu.start_pressed = true;
Expand All @@ -432,10 +431,14 @@ impl Application for YourApp {
self.game.has_ended = false;
}
Message::Event(Event::Keyboard(keyboard::Event::KeyPressed { key, .. })) => {
self.game.old_board = self.game.board.clone();
let old_board = self.game.board.clone();
self.game
.board
.move_tile_content(key, self.game.menu.height, self.game.menu.width)
.move_tile_content(key, self.game.menu.height, self.game.menu.width);
if old_board != self.game.board {
println!("aaaa");
self.game.old_board = old_board
};
}
Message::Back => self.game.board = self.game.old_board.clone(),
_ => {}
Expand Down

0 comments on commit 0e0e307

Please sign in to comment.