onLockDown

This commit is contained in:
Adrien MALINGREY 2023-07-10 23:31:51 +02:00
parent bf4b296ec0
commit 8279b1188f
2 changed files with 8 additions and 3 deletions

2
app.js
View File

@ -72,7 +72,7 @@ let game = {
generate: function(nextPiece=nextQueue.shift()) {
nextPiece.lockDelay = stats.lockDelay
matrix.piece = nextPiece
matrix.piece.onlockdown = game.lockDown
matrix.piece.onLockDown = game.lockDown
if (matrix.piece.canMove(TRANSLATION.NONE)) {
scheduler.setInterval(game.fall, stats.fallPeriod)

View File

@ -167,14 +167,19 @@ class Tetromino extends AbstractTetromino {
}
if (this.canMove(TRANSLATION.DOWN)) {
this.locking = false
scheduler.clearTimeout(this.onlockdown)
scheduler.clearTimeout(this.onLockDown)
} else {
scheduler.resetTimeout(this.onlockdown, this.lockDelay)
scheduler.resetTimeout(this.onLockDown, this.lockDelay)
this.locking = true
}
if (this.ghost.visible) this.updateGhost()
return true
} else {
this.locked = true
if (!scheduler.timeoutTasks.has(this.onLockDown))
scheduler.setTimeout(this.onLockDown, this.lockDelay)
}
}
rotate(rotation) {