From ced0b76565861a0d74e6412d7c6fe2d39088797e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 7 Sep 2014 20:07:14 +0200 Subject: Added pressing escape to restart the game --- game/states/play.js | 10 ++++++++++ todo.md | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3