Added score.

This commit is contained in:
Robert Kolner committed 2012-03-16 14:59:30 +01:00
1 parent 24cdb2715f
commit 59a7eb083f
1 file changed
+17 -1
+17 -1
View File
@@ -28,7 +28,9 @@ function TetrisGame(id) {
/* Variables: */
/**************/
this.gameIsOver = false;
this.gameLinesCleared = 0;
this.gameScore = 0;
this.width = 10;
this.height = 15;
this.canvas = new TetrisCanvas(id, this.width, this.height);
@@ -54,6 +56,17 @@ function TetrisGame(id) {
this.drawCurrentBrick();
}
this.xyToTileIndex = function(x,y) {
return y * this.width + x;
}
this.tileIndexToXY = function(tileIndex) {
var y = Math.floor(tileIndex / this.width);
var x = tileIndex % y;
return [x,y];
}
this.getRandomBrick = function() {
return 1 + Math.floor(Math.random() * 7);
}
@@ -253,6 +266,9 @@ function TetrisGame(id) {
for (var i = 0; i < filledLines.length; i++) {
this.removeLine(filledLines[i]-i);
}
this.gameScore += filledLines.length * 100;
this.gameLinesCleared += filledLines.length;
this.drawUnlock();
this.redraw();