feat: music & sound!!!
This commit is contained in:
@@ -24,6 +24,10 @@ public class Space {
|
||||
nextShape = getNextShape();
|
||||
}
|
||||
|
||||
public Tetromino getCurrentTetromino() {
|
||||
return currentTetromino;
|
||||
}
|
||||
|
||||
public TetrominoShape getNextShape() {
|
||||
return TetrominoShape.values()[random.nextInt(TetrominoShape.values().length)];
|
||||
}
|
||||
@@ -60,14 +64,14 @@ public class Space {
|
||||
int combo = 0;
|
||||
Set<Integer> completedLines = new TreeSet<>();
|
||||
for (int line : lines) {
|
||||
if (line > getMapHeight()) continue;
|
||||
if (line >= getMapHeight()) continue;
|
||||
Color[] newBlobs = tetromino.getLine(line);
|
||||
for (int i = 0; i < newBlobs.length; i++) {
|
||||
if (newBlobs[i] == null) continue;
|
||||
gameMap[line][i] = newBlobs[i];
|
||||
}
|
||||
if (Arrays.stream(gameMap[line]).noneMatch(Objects::isNull)) { // Line completed
|
||||
combo += 1;
|
||||
combo += 10;
|
||||
completedLines.add(line);
|
||||
combo *= completedLines.size();
|
||||
}
|
||||
@@ -78,11 +82,11 @@ public class Space {
|
||||
gameMap[i] = (i-1 < 0) ? new Color[gameMap[i].length] : gameMap[i-1];
|
||||
}
|
||||
}
|
||||
this.score += combo;
|
||||
Tetris.updateScore(this.score);
|
||||
increaseScore(combo);
|
||||
}
|
||||
|
||||
public Tetromino getCurrentTetromino() {
|
||||
return currentTetromino;
|
||||
public void increaseScore(int amount) {
|
||||
this.score += amount;
|
||||
Tetris.updateScore(this.score);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user