Added few more controls.

This commit is contained in:
Robert Kolner committed 2012-03-13 02:03:07 +01:00
1 parent a7379e149e
commit 4f0d922aa5
2 files changed
+24

No files matched your search

+10
View File
@@ -16,6 +16,16 @@ function onKeyPressed(e) {
game.moveCurrentBrickHorizontally(1);
return;
}
if (String.fromCharCode(e.charCode) == 's') {
game.moveCurrentBrickDown();
return;
}
if (String.fromCharCode(e.charCode) == 'w') {
game.rotateCurrentBrick();
return;
}
}
$(document).ready(function() {
+14
View File
@@ -112,6 +112,11 @@ function TetrisGame(id) {
return true;
}
this.canCurrentBrickRotate = function() {
/* TODO!! */
return true;
}
this.moveCurrentBrickHorizontally = function(dx) {
if (this.canCurrentBrickMove(dx, 0)) {
this.currentBrickLoc[0] += dx;
@@ -141,6 +146,15 @@ function TetrisGame(id) {
return false;
}
this.rotateCurrentBrick = function() {
if (this.canCurrentBrickRotate()) {
this.currentBrickRot = (this.currentBrickRot + 1) % 4;
this.redraw();
return true;
}
return false;
}
this.doTurn = function() {
/* Fill out */
this.moveCurrentBrickDown();