Added score.

This commit is contained in:
Robert Kolner committed 2012-03-18 21:24:14 +01:00
commit 53efb6a534
2 files changed
+22 -1

No files matched your search

+12 -1
View File
@@ -29,7 +29,7 @@ function TetrisGame(id, linesId) {
/**************/
this.gameIsOver = false;
this.linesCleared = 0;
this.width = 10;
this.height = 15;
this.canvas = new TetrisCanvas(id, this.width, this.height, linesId);
@@ -55,6 +55,17 @@ function TetrisGame(id, linesId) {
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);
}
+10
View File
@@ -10,3 +10,13 @@ function createArray(length) {
return a;
}
function arrayContains(array, element) {
for (var i = 0; i < array.length; i++) {
if (array[i] == element) {
return true;
}
}
return false;
}