Added score.
This commit is contained in:
commit
53efb6a534
2 files changed
+22
-1
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user