fix lines clear
This commit is contained in:
parent
29387428b6
commit
32b1799c6b
@ -56,6 +56,7 @@ const T_SLOT = {
|
|||||||
C: 3,
|
C: 3,
|
||||||
D: 2
|
D: 2
|
||||||
}
|
}
|
||||||
|
const T_SLOT_POS = [[-1, -1], [1, -1], [1, 1], [-1, 1]]
|
||||||
const SCORES = [
|
const SCORES = [
|
||||||
{linesClearedName: "", "": 0, "MINI\nT-SPIN": 1, "T-SPIN": 4},
|
{linesClearedName: "", "": 0, "MINI\nT-SPIN": 1, "T-SPIN": 4},
|
||||||
{linesClearedName: "SINGLE", "": 1, "MINI\nT-SPIN": 2, "T-SPIN": 8},
|
{linesClearedName: "SINGLE", "": 1, "MINI\nT-SPIN": 2, "T-SPIN": 8},
|
||||||
@ -64,7 +65,6 @@ const SCORES = [
|
|||||||
{linesClearedName: "TETRIS", "": 8},
|
{linesClearedName: "TETRIS", "": 8},
|
||||||
]
|
]
|
||||||
const REPEATABLE_ACTIONS = [moveLeft, moveRight, softDrop]
|
const REPEATABLE_ACTIONS = [moveLeft, moveRight, softDrop]
|
||||||
const T_SLOT_POS = [[-1, -1], [1, -1], [1, 1], [-1, 1]]
|
|
||||||
const STATE = {
|
const STATE = {
|
||||||
PLAYING: "PLAYING",
|
PLAYING: "PLAYING",
|
||||||
PAUSED: "PAUSE",
|
PAUSED: "PAUSE",
|
||||||
@ -413,6 +413,7 @@ class Matrix {
|
|||||||
this.piece.draw(this.context, ghost_pos)
|
this.piece.draw(this.context, ghost_pos)
|
||||||
|
|
||||||
// Lines cleared
|
// Lines cleared
|
||||||
|
console.log(this.linesCleared.length)
|
||||||
if (this.linesCleared.length) {
|
if (this.linesCleared.length) {
|
||||||
this.context.save()
|
this.context.save()
|
||||||
this.context.shadowColor = "white"
|
this.context.shadowColor = "white"
|
||||||
@ -554,9 +555,9 @@ function locksDown(){
|
|||||||
|
|
||||||
// T-Spin detection
|
// T-Spin detection
|
||||||
var tSpin = T_SPIN.NONE
|
var tSpin = T_SPIN.NONE
|
||||||
const tSlots = T_SLOT_POS.translate(matrix.piece.pos).map(pos => matrix.cellIsOccupied(pos))
|
|
||||||
if (matrix.piece.rotatedLast && matrix.piece.shape == "T") {
|
if (matrix.piece.rotatedLast && matrix.piece.shape == "T") {
|
||||||
const a = tSlots[(matrix.piece.orientation+T_SLOT.A)%4],
|
const tSlots = T_SLOT_POS.translate(matrix.piece.pos).map(pos => matrix.cellIsOccupied(pos)),
|
||||||
|
a = tSlots[(matrix.piece.orientation+T_SLOT.A)%4],
|
||||||
b = tSlots[(matrix.piece.orientation+T_SLOT.B)%4],
|
b = tSlots[(matrix.piece.orientation+T_SLOT.B)%4],
|
||||||
c = tSlots[(matrix.piece.orientation+T_SLOT.C)%4],
|
c = tSlots[(matrix.piece.orientation+T_SLOT.C)%4],
|
||||||
d = tSlots[(matrix.piece.orientation+T_SLOT.D)%4]
|
d = tSlots[(matrix.piece.orientation+T_SLOT.D)%4]
|
||||||
@ -575,9 +576,10 @@ function locksDown(){
|
|||||||
matrix.linesCleared.push((y-3) * MINO_SIZE)
|
matrix.linesCleared.push((y-3) * MINO_SIZE)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
scheduler.setTimeout(clearLinesCleared, ANIMATION_DELAY)
|
|
||||||
|
|
||||||
stats.locksDown(tSpin, matrix.linesCleared.length)
|
stats.locksDown(tSpin, matrix.linesCleared.length)
|
||||||
|
requestAnimationFrame(draw)
|
||||||
|
scheduler.setTimeout(clearLinesCleared, ANIMATION_DELAY)
|
||||||
|
|
||||||
if (stats.goal <= 0)
|
if (stats.goal <= 0)
|
||||||
newLevel()
|
newLevel()
|
||||||
@ -588,6 +590,7 @@ function locksDown(){
|
|||||||
|
|
||||||
function clearLinesCleared() {
|
function clearLinesCleared() {
|
||||||
matrix.linesCleared = []
|
matrix.linesCleared = []
|
||||||
|
requestAnimationFrame(draw)
|
||||||
}
|
}
|
||||||
|
|
||||||
function gameOver() {
|
function gameOver() {
|
||||||
|
Reference in New Issue
Block a user