Sound & favicon

This commit is contained in:
Adrien MALINGREY 2023-06-19 02:51:25 +02:00
parent b9ff06f32d
commit d5eb58334c
8 changed files with 22 additions and 13 deletions

23
app.js
View File

@ -350,7 +350,6 @@ class Tetromino extends THREE.Group {
let testFacing = (this.facing + rotation + 4) % 4 let testFacing = (this.facing + rotation + 4) % 4
return this.srs[this.facing][rotation].some((translation, rotationPoint) => { return this.srs[this.facing][rotation].some((translation, rotationPoint) => {
if (this.move(translation, testFacing)) { if (this.move(translation, testFacing)) {
//rotateSound.play()
this.facing = testFacing this.facing = testFacing
this.rotatedLast = true this.rotatedLast = true
if (rotationPoint == 4) this.rotationPoint4Used = true if (rotationPoint == 4) this.rotationPoint4Used = true
@ -898,8 +897,10 @@ nextQueue.position.set(4, SKYLINE + 3)
scene.add(nextQueue) scene.add(nextQueue)
let ghost = new Ghost() let ghost = new Ghost()
const lineClearSound = new Audio("audio/line_clear.ogg") const lineClearSound = new Audio("audio/line-clear.wav")
const tetrisSound = new Audio("audio/tetris.ogg") const tetrisSound = new Audio("audio/tetris.wav")
const hardDropSound = new Audio("audio/hard-drop.wav")
const tSpinSound = new Audio("audio/t-spin.wav")
const music = new Audio("https://iterations.org/files/music/remixes/Tetris_CheDDer_OC_ReMix.mp3") const music = new Audio("https://iterations.org/files/music/remixes/Tetris_CheDDer_OC_ReMix.mp3")
music.loop = true music.loop = true
@ -1016,6 +1017,8 @@ function resume(event) {
lineClearSound.volume = settings.sfxVolume lineClearSound.volume = settings.sfxVolume
tetrisSound.volume = settings.sfxVolume tetrisSound.volume = settings.sfxVolume
hardDropSound.volume = settings.sfxVolume
tSpinSound.volume = settings.sfxVolume
if (settings.musicVolume > 0) { if (settings.musicVolume > 0) {
music.volume = settings.musicVolume music.volume = settings.musicVolume
music.play() music.play()
@ -1060,7 +1063,11 @@ let playerActions = {
hardDrop: function () { hardDrop: function () {
scheduler.clearTimeout(lockDown) scheduler.clearTimeout(lockDown)
//hardDropSound.play() hardDropSound.play()
if (settings.sfxVolume) {
hardDropSound.currentTime = 0
hardDropSound.play()
}
while (piece.move(TRANSLATION.DOWN)) stats.score += 2 while (piece.move(TRANSLATION.DOWN)) stats.score += 2
lockDown() lockDown()
}, },
@ -1153,12 +1160,14 @@ function lockDown() {
scene.remove(piece) scene.remove(piece)
let tSpin = piece.tSpin let tSpin = piece.tSpin
let nbClearedLines = matrix.clearLines() let nbClearedLines = matrix.clearLines()
if (nbClearedLines == 4 || (nbClearedLines && tSpin)) { if (settings.sfxVolume) {
if (nbClearedLines == 4 || (tSpin && nbClearedLines)) {
tetrisSound.currentTime = 0 tetrisSound.currentTime = 0
if (tetrisSound.volume) tetrisSound.play() tetrisSound.play()
} else if (nbClearedLines || tSpin) { } else if (nbClearedLines || tSpin) {
lineClearSound.currentTime = 0 lineClearSound.currentTime = 0
if (lineClearSound.volume) lineClearSound.play() lineClearSound.play()
}
} }
stats.lockDown(nbClearedLines, tSpin) stats.lockDown(nbClearedLines, tSpin)

BIN
audio/hard-drop.wav Normal file

Binary file not shown.

BIN
audio/line-clear.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
audio/tetris.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 118 KiB