feat: add line completed sound

This commit is contained in:
Martin Prokoph
2025-06-29 15:06:01 +02:00
parent 0a2294cd3d
commit f226cb40e2
8 changed files with 5 additions and 7 deletions

View File

@@ -28,10 +28,6 @@ public class Tetris {
ui = new TetrisUI(); ui = new TetrisUI();
} }
public static TetrisUI getUi() {
return ui;
}
public static Space getSpace() { public static Space getSpace() {
return space; return space;
} }

View File

@@ -1,6 +1,7 @@
package eu.midnightdust.yaytris.game; package eu.midnightdust.yaytris.game;
import eu.midnightdust.yaytris.Tetris; import eu.midnightdust.yaytris.Tetris;
import eu.midnightdust.yaytris.util.SoundEffect;
import java.awt.Color; import java.awt.Color;
import java.util.*; import java.util.*;
@@ -76,6 +77,7 @@ public class Space {
combo *= completedLines.size(); combo *= completedLines.size();
} }
} }
if (!completedLines.isEmpty()) SoundEffect.LINE_COMPLETED.play();
for (int completedIndex = 0; completedIndex < completedLines.size(); completedIndex++) { // Remove completed lines for (int completedIndex = 0; completedIndex < completedLines.size(); completedIndex++) { // Remove completed lines
int line = completedLines.toArray(new Integer[0])[completedIndex]; int line = completedLines.toArray(new Integer[0])[completedIndex];
for (int i = line; i >= 0; i--) { for (int i = line; i >= 0; i--) {

View File

@@ -21,7 +21,7 @@ public class Tetromino {
public boolean fall() { public boolean fall() {
Vec2i newPos = centerPos.offset(Vec2i.of(0, 1)); Vec2i newPos = centerPos.offset(Vec2i.of(0, 1));
if (collidesVertically(newPos)) { if (collidesVertically(newPos)) {
SoundEffect.BEEP.play(); SoundEffect.BOOP.play();
int[] affectedLines = new int[this.collision.length]; int[] affectedLines = new int[this.collision.length];
int line = centerPos.getY(); int line = centerPos.getY();
for (int i = 0; i < this.collision.length; i++) { for (int i = 0; i < this.collision.length; i++) {

View File

@@ -1,7 +1,7 @@
package eu.midnightdust.yaytris.util; package eu.midnightdust.yaytris.util;
public enum SoundEffect { public enum SoundEffect {
BEEP("/sounds/beep.wav"); BOOP("/sounds/boop.wav"), LINE_COMPLETED("/sounds/line-completed.wav");
final String location; final String location;
SoundEffect(String location) { SoundEffect(String location) {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,5 +1,5 @@
{ {
"musicVolume": 100, "musicVolume": 25,
"soundVolume": 100, "soundVolume": 100,
"guiScale": 5.0, "guiScale": 5.0,
"difficulty": "NORMAL" "difficulty": "NORMAL"