no wall nound on hard drop

This commit is contained in:
Adrien MALINGREY 2023-12-07 20:02:43 +01:00
parent a04e118ff1
commit a89a60691c
2 changed files with 5 additions and 7 deletions

View File

@ -119,9 +119,9 @@ let playerActions = {
hardDrop: function() { hardDrop: function() {
scheduler.clearTimeout(lockDown) scheduler.clearTimeout(lockDown)
playSound(hardDropSound) playSound(hardDropSound)
while (matrix.piece.move(TRANSLATION.DOWN, ROTATION.NONE, true)) stats.score +=2 while (matrix.piece.move(TRANSLATION.DOWN, ROTATION.NONE, true)) stats.score += 2
matrix.table.classList.add("hard-dropped-table-animation") matrix.table.classList.add("hard-dropped-table-animation")
lockDown() lockDown(true)
return true return true
}, },
@ -215,10 +215,10 @@ function fall() {
matrix.piece.move(TRANSLATION.DOWN) matrix.piece.move(TRANSLATION.DOWN)
} }
function lockDown() { function lockDown(hardDropped=false) {
scheduler.clearTimeout(lockDown) scheduler.clearTimeout(lockDown)
scheduler.clearInterval(fall) scheduler.clearInterval(fall)
if (lastActionSucceded) wallSound.play() if (lastActionSucceded && !hardDropped) playSound(wallSound)
if (matrix.lock()) { if (matrix.lock()) {
let tSpin = matrix.piece.tSpin let tSpin = matrix.piece.tSpin

View File

@ -349,13 +349,11 @@ class Tetromino {
} }
matrix.drawPiece() matrix.drawPiece()
return true return true
} else if (!hardDropped) { } else if (!hardDropped && translation == TRANSLATION.DOWN) {
if (translation == TRANSLATION.DOWN) {
this.locked = true this.locked = true
if (!scheduler.timeoutTasks.has(lockDown)) if (!scheduler.timeoutTasks.has(lockDown))
scheduler.setTimeout(lockDown, stats.lockDelay) scheduler.setTimeout(lockDown, stats.lockDelay)
matrix.drawPiece() matrix.drawPiece()
}
} }
} }