feat: add difficulty setting

This commit is contained in:
Martin Prokoph
2025-06-28 00:01:00 +02:00
parent 2ca0fcfd86
commit 41af446f94
6 changed files with 44 additions and 17 deletions

View File

@@ -6,12 +6,12 @@ import eu.midnightdust.yaytris.ui.TetrisUI;
import javax.swing.*;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
public class Tetris {
public static final Random random = new Random();
public static Space space;
static TetrisUI ui;
public static Timer timer;
public static TetrisUI ui;
public static void main(String[] args) {
try {
@@ -19,17 +19,8 @@ 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();
timer = new Timer("Tetris falling pieces");
space = new Space();
ui = new TetrisUI();
Timer timer = new Timer("Tetris falling pieces");
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (Tetris.space.getCurrentTetromino() != null) {
Tetris.space.getCurrentTetromino().fall(1);
Tetris.ui.getGamePanel().repaint();
}
}
}, 50, 1000);
}
}