Added lock for more smooth redrawing.
This commit is contained in:
1 parent
790f9ed965
commit
205748edd8
1 file changed
+11
@@ -39,7 +39,15 @@ function TetrisGame(id) {
|
||||
/**************/
|
||||
/* Functions: */
|
||||
/**************/
|
||||
this.drawLocker = false;
|
||||
this.drawLock = function() { this.drawLocker = true; };
|
||||
this.drawUnlock = function() { this.drawLocker = false; };
|
||||
|
||||
this.redraw = function() {
|
||||
if (this.drawLocker) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.canvas.drawBoard(this.board);
|
||||
this.drawCurrentBrick();
|
||||
}
|
||||
@@ -230,7 +238,9 @@ function TetrisGame(id) {
|
||||
}
|
||||
|
||||
this.doTurn = function() {
|
||||
this.drawLock();
|
||||
if (! this.moveCurrentBrickDown()) {
|
||||
this.drawUnlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -238,6 +248,7 @@ function TetrisGame(id) {
|
||||
for (var i = 0; i < filledLines.length; i++) {
|
||||
this.removeLine(filledLines[i]-i);
|
||||
}
|
||||
this.drawUnlock();
|
||||
this.redraw();
|
||||
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user