onLockDown
This commit is contained in:
2
app.js
2
app.js
@ -72,7 +72,7 @@ let game = {
|
|||||||
generate: function(nextPiece=nextQueue.shift()) {
|
generate: function(nextPiece=nextQueue.shift()) {
|
||||||
nextPiece.lockDelay = stats.lockDelay
|
nextPiece.lockDelay = stats.lockDelay
|
||||||
matrix.piece = nextPiece
|
matrix.piece = nextPiece
|
||||||
matrix.piece.onlockdown = game.lockDown
|
matrix.piece.onLockDown = game.lockDown
|
||||||
|
|
||||||
if (matrix.piece.canMove(TRANSLATION.NONE)) {
|
if (matrix.piece.canMove(TRANSLATION.NONE)) {
|
||||||
scheduler.setInterval(game.fall, stats.fallPeriod)
|
scheduler.setInterval(game.fall, stats.fallPeriod)
|
||||||
|
@ -167,14 +167,19 @@ class Tetromino extends AbstractTetromino {
|
|||||||
}
|
}
|
||||||
if (this.canMove(TRANSLATION.DOWN)) {
|
if (this.canMove(TRANSLATION.DOWN)) {
|
||||||
this.locking = false
|
this.locking = false
|
||||||
scheduler.clearTimeout(this.onlockdown)
|
scheduler.clearTimeout(this.onLockDown)
|
||||||
} else {
|
} else {
|
||||||
scheduler.resetTimeout(this.onlockdown, this.lockDelay)
|
scheduler.resetTimeout(this.onLockDown, this.lockDelay)
|
||||||
this.locking = true
|
this.locking = true
|
||||||
}
|
}
|
||||||
if (this.ghost.visible) this.updateGhost()
|
if (this.ghost.visible) this.updateGhost()
|
||||||
return true
|
return true
|
||||||
|
} else {
|
||||||
|
this.locked = true
|
||||||
|
if (!scheduler.timeoutTasks.has(this.onLockDown))
|
||||||
|
scheduler.setTimeout(this.onLockDown, this.lockDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rotate(rotation) {
|
rotate(rotation) {
|
||||||
|
Reference in New Issue
Block a user