feat: save highscores

This commit is contained in:
Martin Prokoph
2025-08-01 19:07:20 +02:00
parent 8037f9a323
commit 93c0ee5f95
4 changed files with 33 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ public class Tetris {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception | Error e) { System.out.printf("%s: %s\n", "Error setting system look and feel", e); }
Settings.load();
HighScores.load();
timer = new Timer("Tetris falling pieces");
space = new Space();
ui = new TetrisUI();
@@ -51,6 +52,7 @@ public class Tetris {
public static void stopGame() {
SoundUtil.stopMusic("/music/theme.wav");
HighScores.addScore(space.getScore());
if (gravityTask != null) gravityTask.cancel();
timer.purge();
if (ui.getMenuPanel() instanceof ScoreMenu) ((ScoreMenu) ui.getMenuPanel()).gameOver();