refactored reset game

This commit is contained in:
2025-12-16 13:57:52 +01:00
parent ce3f590715
commit 54a2ee3022
5 changed files with 20 additions and 10 deletions

View File

@@ -263,18 +263,16 @@ public class GamePanel extends JPanel implements Runnable {
fScreenWidth = Boot.window.getWidth();
fScreenHeight = Boot.window.getHeight();
}
public void retry() {
public void resetGame(boolean restart) {
player.setDefaultPositions();
player.restoreLife();
player.restoreStatus();
assetSetter.setNPC();
assetSetter.setMonster();
}
public void restart() {
if(!restart) return;
player.setDefaultValues();
assetSetter.setObject();
assetSetter.setNPC();
assetSetter.setMonster();
assetSetter.setITiles();
eManager.lighting.resetDay();
}
}

View File

@@ -736,6 +736,7 @@ public class UI {
if(commandNum == 1) {
graphics2d.drawString(">", textX-25, textY);
if(panel.keyH.spacePressed) optionState = OptionState.OVERVIEW;
panel.resetGame(true);
}
}

View File

@@ -152,12 +152,12 @@ public class KeyHandler implements KeyListener {
if(panel.ui.commandNum == 0) {
panel.gameState = GameState.PLAY;
panel.playMusic(0);
panel.retry();
panel.resetGame(false);
}
if(panel.ui.commandNum == 1) {
panel.gameState = GameState.TITLE;
panel.ui.commandNum = 0;
panel.restart();
panel.resetGame(true);
panel.stopMusic();
}
}