remove game board on win or lose

This commit is contained in:
Luca Conte 2024-12-23 20:13:52 +01:00
parent 44f04a454f
commit 9d51e708e5
1 changed files with 10 additions and 0 deletions

View File

@ -134,6 +134,12 @@ public class MainFrame extends JFrame {
if(player != gameBoard.getP1()){
return;
}
this.gameBoard.getP1().destroy();
this.gameBoard.getP2().destroy();
this.gameBoard.removeAll();
this.gameBoard = null;
WinScreen winScreen = new WinScreen(this);
mainPanel.add(winScreen, panelName);
mainPanel.revalidate();
@ -151,8 +157,12 @@ public class MainFrame extends JFrame {
if(player != gameBoard.getP1()){
return;
}
this.gameBoard.getP1().destroy();
this.gameBoard.getP2().destroy();
this.gameBoard.removeAll();
this.gameBoard = null;
LoseScreen looseScreen = new LoseScreen(this);
mainPanel.add(looseScreen,panelName);
mainPanel.revalidate();