Added few more controls.
This commit is contained in:
1 parent
a7379e149e
commit
4f0d922aa5
2 files changed
+24
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user