feat: music & sound!!!

This commit is contained in:
Martin Prokoph
2025-06-29 13:53:48 +02:00
parent 082ff42208
commit 8e7a96ad11
7 changed files with 183 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
package eu.midnightdust.yaytris.game;
import eu.midnightdust.yaytris.Tetris;
import eu.midnightdust.yaytris.util.SoundEffect;
import eu.midnightdust.yaytris.util.Vec2i;
import java.awt.*;
@@ -20,6 +21,7 @@ public class Tetromino {
public void fall(int length) {
Vec2i newPos = centerPos.offset(Vec2i.of(0, length));
if (collidesVertically(newPos)) {
SoundEffect.BEEP.play();
int[] affectedLines = new int[this.collision.length];
int line = centerPos.getY();
for (int i = 0; i < this.collision.length; i++) {
@@ -27,6 +29,7 @@ public class Tetromino {
line++;
}
Tetris.getSpace().onLinesChanged(this, affectedLines);
Tetris.getSpace().increaseScore(20-fallLength);
if (fallLength >= 1) Tetris.getSpace().spawnTetromino();
else Tetris.stopGame();
}