combo sound
This commit is contained in:
parent
c9b242c9c2
commit
3345a50803
16
app.js
16
app.js
@ -88,16 +88,14 @@ let game = {
|
||||
if (playfield.lock(playfield.piece)) {
|
||||
let tSpin = playfield.piece.tSpin
|
||||
let nbClearedLines = playfield.clearLines()
|
||||
stats.lockDown(nbClearedLines, tSpin)
|
||||
if (settings.sfxVolume) {
|
||||
if (nbClearedLines == 4 || (tSpin && nbClearedLines)) {
|
||||
scene.tetrisSound.stop()
|
||||
scene.tetrisSound.play()
|
||||
playSound(scene.tetrisSound, stats.combo)
|
||||
} else if (nbClearedLines || tSpin) {
|
||||
scene.lineClearSound.stop()
|
||||
scene.lineClearSound.play()
|
||||
playSound(scene.lineClearSound, stats.combo)
|
||||
}
|
||||
}
|
||||
stats.lockDown(nbClearedLines, tSpin)
|
||||
|
||||
game.generate()
|
||||
} else {
|
||||
@ -146,6 +144,14 @@ let game = {
|
||||
}
|
||||
|
||||
|
||||
function playSound(sound, note=0) {
|
||||
sound.stop()
|
||||
sound.currentTime = 0
|
||||
sound.playbackRate = Math.pow(5/4, note)
|
||||
sound.play()
|
||||
}
|
||||
|
||||
|
||||
/* Handle player inputs */
|
||||
|
||||
let playerActions = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user