Added statistics.

This commit is contained in:
Robert Kolner committed 2012-03-22 20:17:02 +01:00
1 parent f2c49ecc40
commit c392235b11
4 files changed
+44 -4

No files matched your search

+6 -3
View File
@@ -28,7 +28,8 @@ function TetrisGame(canvasId, linesCounterId, nextBricksCanvasId) {
/* Variables: */
/**************/
this.gameIsOver = false;
this.linesCleared = 0;
this.stats = new TetrisStats();
this.width = 10;
this.height = 15;
@@ -125,6 +126,7 @@ function TetrisGame(canvasId, linesCounterId, nextBricksCanvasId) {
this.currentBrickRot = 0;
this.currentBrickLoc = this.getBrickStartingLocation(this.currentBrickId);
this.stats.newBrick(this.currentBrickId);
this.redraw();
}
}
@@ -294,7 +296,7 @@ function TetrisGame(canvasId, linesCounterId, nextBricksCanvasId) {
this.updateLineCounter = function() {
if (this.lineCounterElement != 0) {
this.lineCounterElement.html('' +this.linesCleared);
this.lineCounterElement.html('' +this.stats.countLinesCleared);
}
}
@@ -310,9 +312,10 @@ function TetrisGame(canvasId, linesCounterId, nextBricksCanvasId) {
this.removeLine(filledLines[i]-i);
}
this.linesCleared += filledLines.length;
this.stats.linesCleared(filledLines.length);
this.updateLineCounter();
this.drawUnlock();
this.redraw();