summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-09-07 20:07:14 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-09-07 20:07:14 +0200
commitced0b76565861a0d74e6412d7c6fe2d39088797e (patch)
treedb63cb1ea7696fb1278ae7f861d07fbf77d8d6ce
parentc5c2da57e2ddb7c8f781852d78164702c46c551b (diff)
Added pressing escape to restart the game
-rw-r--r--game/states/play.js10
-rw-r--r--todo.md1
2 files changed, 10 insertions, 1 deletions
diff --git a/game/states/play.js b/game/states/play.js
index 845fa8f..26242b3 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -238,6 +238,9 @@ Play.prototype = {
right: Phaser.Keyboard.RIGHT,
poison: Phaser.Keyboard.ENTER
};
+ this.controls = {
+ reset: Phaser.Keyboard.ESC
+ };
function addKeyCaptures(controls, keyboard) {
for (var index in controls) {
@@ -248,6 +251,7 @@ Play.prototype = {
}
addKeyCaptures(this.playerAControls, this.game.input.keyboard);
addKeyCaptures(this.playerBControls, this.game.input.keyboard);
+ addKeyCaptures(this.controls, this.game.input.keyboard);
this.game.input.gamepad.start();
@@ -266,6 +270,10 @@ Play.prototype = {
this.game.input.keyboard.addKey(this.playerBControls.poison).onDown.add(this.togglePoisonPill.bind(this, this.playerB), this);
this.game.input.keyboard.addKey(this.playerAControls.poison).onDown.add(this.togglePoisonPill.bind(this, this.playerA), this);
+
+ this.game.input.keyboard.addKey(this.controls.reset).onDown.add(function() {
+ this.game.state.start('play');
+ },this);
},
togglePoisonPill: function(player) {
if (player.hasPoisonPill) {
@@ -400,6 +408,8 @@ Play.prototype = {
this.game.input.keyboard.removeKey(this.playerBControls.down);
this.game.input.keyboard.removeKey(this.playerBControls.left);
this.game.input.keyboard.removeKey(this.playerBControls.right);
+
+ this.game.input.keyboard.removeKey(this.controls.reset);
}
};
diff --git a/todo.md b/todo.md
index 69eebda..d89385a 100644
--- a/todo.md
+++ b/todo.md
@@ -2,6 +2,5 @@ TODO
====
* Add tutorial / instructions page
-* Add reset / end game early mechanism
* Refine orientation controls
* Read in game playback