lines cleared
This commit is contained in:
		| @ -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,13 +308,20 @@ 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++) { | ||||||
|                 for (var x=0; x < this.columns; x++) { |                 if (this.linesCleared.includes(y)) { | ||||||
|                     var cell = this.table.rows[y].cells[x] |                     for (var x=0; x < this.columns; x++) { | ||||||
|                     var bgColor = this.lockedMinoes[y][x] |                         var cell = this.table.rows[y].cells[x] | ||||||
|                     if (bgColor) drawMino(cell, bgColor, MINO_BORDER_COLOR) |                         drawMino(cell, LINE_CLEARED_COLOR, LINE_CLEARED_COLOR) | ||||||
|                     else { |                     } | ||||||
|                         if (y < 4) drawMino(cell, this.defaultBgColor, "transparent") |                 } else { | ||||||
|                         else drawMino(cell, this.defaultBgColor, MATRIX_BORDER_COLOR) |                     for (var x=0; x < this.columns; x++) { | ||||||
|  |                         var cell = this.table.rows[y].cells[x] | ||||||
|  |                         var bgColor = this.lockedMinoes[y][x] | ||||||
|  |                         if (bgColor) drawMino(cell, bgColor, MINO_BORDER_COLOR) | ||||||
|  |                         else { | ||||||
|  |                             if (y < MATRIX_INVISIBLE_ROWS) drawMino(cell, this.defaultBgColor, MATRIX_INVISIBLE_BORDER_COLOR) | ||||||
|  |                             else drawMino(cell, this.defaultBgColor, MATRIX_BORDER_COLOR) | ||||||
|  |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @ -326,15 +336,15 @@ class Matrix extends MinoesTable { | |||||||
|                 }) |                 }) | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             var ghost = this.piece.ghost |             //ghost | ||||||
|             for (; this.spaceToMove(ghost.minoesAbsPos); ghost.pos[1]++) {} |             if (!this.piece.locked) { | ||||||
|             ghost.pos[1]-- |                 var ghost = this.piece.ghost | ||||||
|             ghost.drawIn(this.table) |                 for (; this.spaceToMove(ghost.minoesAbsPos); ghost.pos[1]++) {} | ||||||
|             this.piece.drawIn(this.table) |                 ghost.pos[1]-- | ||||||
|  |                 ghost.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