feat: preview of next shape
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user