Added arrows as controls.
This commit is contained in:
1 parent
07ada7b421
commit
24cdb2715f
1 file changed
+17
-1
+17
-1
@@ -9,9 +9,25 @@ function initControls() {
|
||||
|
||||
function onKeyDown(e) {
|
||||
var ascii_space = 32;
|
||||
|
||||
var ascii_left = 37;
|
||||
var ascii_right = 39;
|
||||
var ascii_down = 40;
|
||||
var ascii_up = 38;
|
||||
|
||||
if (e.keyCode == ascii_space) {
|
||||
game.hardDrop();
|
||||
} else if (e.keyCode == ascii_left) {
|
||||
game.moveCurrentBrickHorizontally(-1);
|
||||
} else if (e.keyCode == ascii_right) {
|
||||
game.moveCurrentBrickHorizontally(1);
|
||||
} else if (e.keyCode == ascii_up) {
|
||||
if (! wasRecentlyRotated) {
|
||||
game.rotateCurrentBrick();
|
||||
wasRecentlyRotated = true;
|
||||
}
|
||||
return;
|
||||
} else if (e.keyCode == ascii_down) {
|
||||
game.moveCurrentBrickDown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user