feat: preview of next shape

This commit is contained in:
Martin Prokoph
2025-07-09 13:00:48 +02:00
parent 7671bdec04
commit 7ef6e246ff
9 changed files with 99 additions and 13 deletions

View File

@@ -16,23 +16,27 @@ public class Space {
public Space() {
gameMap = new Color[14][8];
nextShape = getNextShape();
nextShape = generateNextShape();
score = 0;
}
public void spawnTetromino() {
currentTetromino = new Tetromino(nextShape);
nextShape = getNextShape();
nextShape = generateNextShape();
}
public Tetromino getCurrentTetromino() {
return currentTetromino;
}
public TetrominoShape getNextShape() {
public TetrominoShape generateNextShape() {
return TetrominoShape.values()[random.nextInt(TetrominoShape.values().length)];
}
public TetrominoShape getNextShape() {
return nextShape;
}
public int getMapWidth() {
return gameMap[0].length;
}

View File

@@ -41,8 +41,17 @@ public enum TetrominoShape {
final int[][] boundary;
final Color color;
TetrominoShape(int[][] boundary, Color color) {
this.boundary = boundary;
this.color = color;
}
public int[][] getBoundary() {
return boundary;
}
public Color getColor() {
return color;
}
}