Clean the pieces position when restarting the game
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

without that, the old pieces where still in game and this would break
the gameplay
This commit is contained in:
Debucquoy Anthony 2023-05-18 22:08:10 +02:00
parent fed275ba09
commit 5c4e87ea60
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
2 changed files with 10 additions and 0 deletions

View File

@ -124,4 +124,13 @@ public class Map extends Shape{
throw new RuntimeException(e);
}
}
/**
* set the position of each pieces in the map to null
*/
public void resetPiecesPositions(){
for (Piece p : pieces) {
p.setPosition(null);
}
}
}

View File

@ -29,6 +29,7 @@ public class ScreenLevelFinish extends StackPane {
ChooseLvl.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
retry.setOnAction(event -> {
try {
lastlevel.resetPiecesPositions();
Controller.switchRoot(new GameUI(lastlevel));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);