lines cleared
This commit is contained in:
parent
2f07a096be
commit
703638425a
@ -23,6 +23,7 @@ const NEXT_PIECES = 6
|
|||||||
const HOLD_ROWS = 6
|
const HOLD_ROWS = 6
|
||||||
const HOLD_COLUMNS = 6
|
const HOLD_COLUMNS = 6
|
||||||
const MATRIX_ROWS = 24
|
const MATRIX_ROWS = 24
|
||||||
|
const MATRIX_INVISIBLE_ROWS = 4
|
||||||
const MATRIX_COLUMNS = 10
|
const MATRIX_COLUMNS = 10
|
||||||
const NEXT_ROWS = 24
|
const NEXT_ROWS = 24
|
||||||
const NEXT_COLUMNS = 6
|
const NEXT_COLUMNS = 6
|
||||||
@ -30,6 +31,8 @@ const HOLD_BG_COLOR = ""
|
|||||||
const HOLD_BORDER_COLOR = ""
|
const HOLD_BORDER_COLOR = ""
|
||||||
const MATRIX_BG_COLOR = ""
|
const MATRIX_BG_COLOR = ""
|
||||||
const MATRIX_BORDER_COLOR = "#333"
|
const MATRIX_BORDER_COLOR = "#333"
|
||||||
|
const MATRIX_INVISIBLE_BORDER_COLOR = ""
|
||||||
|
const LINE_CLEARED_COLOR = "white"
|
||||||
const NEXT_BG_COLOR = ""
|
const NEXT_BG_COLOR = ""
|
||||||
const NEXT_BORDER_COLOR = ""
|
const NEXT_BORDER_COLOR = ""
|
||||||
const MINO_BORDER_COLOR = "white"
|
const MINO_BORDER_COLOR = "white"
|
||||||
@ -305,16 +308,23 @@ class Matrix extends MinoesTable {
|
|||||||
} else {
|
} else {
|
||||||
// locked minoes
|
// locked minoes
|
||||||
for(var y=0; y < this.rows; y++) {
|
for(var y=0; y < this.rows; y++) {
|
||||||
|
if (this.linesCleared.includes(y)) {
|
||||||
|
for (var x=0; x < this.columns; x++) {
|
||||||
|
var cell = this.table.rows[y].cells[x]
|
||||||
|
drawMino(cell, LINE_CLEARED_COLOR, LINE_CLEARED_COLOR)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (var x=0; x < this.columns; x++) {
|
for (var x=0; x < this.columns; x++) {
|
||||||
var cell = this.table.rows[y].cells[x]
|
var cell = this.table.rows[y].cells[x]
|
||||||
var bgColor = this.lockedMinoes[y][x]
|
var bgColor = this.lockedMinoes[y][x]
|
||||||
if (bgColor) drawMino(cell, bgColor, MINO_BORDER_COLOR)
|
if (bgColor) drawMino(cell, bgColor, MINO_BORDER_COLOR)
|
||||||
else {
|
else {
|
||||||
if (y < 4) drawMino(cell, this.defaultBgColor, "transparent")
|
if (y < MATRIX_INVISIBLE_ROWS) drawMino(cell, this.defaultBgColor, MATRIX_INVISIBLE_BORDER_COLOR)
|
||||||
else drawMino(cell, this.defaultBgColor, MATRIX_BORDER_COLOR)
|
else drawMino(cell, this.defaultBgColor, MATRIX_BORDER_COLOR)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// trail
|
// trail
|
||||||
if (this.trail.height) {
|
if (this.trail.height) {
|
||||||
@ -326,15 +336,15 @@ class Matrix extends MinoesTable {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ghost
|
||||||
|
if (!this.piece.locked) {
|
||||||
var ghost = this.piece.ghost
|
var ghost = this.piece.ghost
|
||||||
for (; this.spaceToMove(ghost.minoesAbsPos); ghost.pos[1]++) {}
|
for (; this.spaceToMove(ghost.minoesAbsPos); ghost.pos[1]++) {}
|
||||||
ghost.pos[1]--
|
ghost.pos[1]--
|
||||||
ghost.drawIn(this.table)
|
ghost.drawIn(this.table)
|
||||||
this.piece.drawIn(this.table)
|
}
|
||||||
|
|
||||||
// Lines cleared
|
this.piece.drawIn(this.table)
|
||||||
/*this.context.fillStyle = "rgba(255, 255, 255, 0.5)"
|
|
||||||
this.linesCleared.forEach(y => this.context.fillRect(0, y, this.width, MINO_SIZE))*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// text
|
// text
|
||||||
@ -541,7 +551,7 @@ function rotate(spin) {
|
|||||||
|
|
||||||
function lockDown(){
|
function lockDown(){
|
||||||
scheduler.clearInterval(lockPhase)
|
scheduler.clearInterval(lockPhase)
|
||||||
if (matrix.piece.minoesAbsPos.every(pos => pos.y < 4))
|
if (matrix.piece.minoesAbsPos.every(pos => pos.y < MATRIX_INVISIBLE_ROWS))
|
||||||
game_over()
|
game_over()
|
||||||
else {
|
else {
|
||||||
matrix.piece.minoesAbsPos.forEach(pos => matrix.lockedMinoes[pos[1]][pos[0]] = matrix.piece.color)
|
matrix.piece.minoesAbsPos.forEach(pos => matrix.lockedMinoes[pos[1]][pos[0]] = matrix.piece.color)
|
||||||
@ -666,7 +676,7 @@ function hardDrop() {
|
|||||||
scheduler.clearInterval(lockPhase)
|
scheduler.clearInterval(lockPhase)
|
||||||
scheduler.clearTimeout(lockDown)
|
scheduler.clearTimeout(lockDown)
|
||||||
matrix.trail.minoesPos = Array.from(matrix.piece.minoesAbsPos)
|
matrix.trail.minoesPos = Array.from(matrix.piece.minoesAbsPos)
|
||||||
for (matrix.trail.height=0; move(MOVEMENT.DOWN); matrix.trail.height ++) {
|
for (matrix.trail.height=0; move(MOVEMENT.DOWN); matrix.trail.height++) {
|
||||||
stats.score += 2
|
stats.score += 2
|
||||||
}
|
}
|
||||||
while (move(MOVEMENT.DOWN)) {}
|
while (move(MOVEMENT.DOWN)) {}
|
||||||
|
Reference in New Issue
Block a user