From 94892a4e24b5c7b9618d6d5ae3e676b11ae8896d Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 31 Aug 2014 09:42:42 +0200 Subject: Added gamepad support for poison pills --- game/prefabs/player.js | 1 + game/states/play.js | 6 ++++++ todo.md | 1 - 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/game/prefabs/player.js b/game/prefabs/player.js index f0a6b65..44c4aa2 100644 --- a/game/prefabs/player.js +++ b/game/prefabs/player.js @@ -25,6 +25,7 @@ var Player = function(game, x, y, key, frame, soundKey) { this.hasPoisonPill = true; this.poisonPillActive = false; + this.gamepadPoisonLastPressed = Number.NEGATIVE_INFINITY; this.lastTween = null; this.scoreSound = game.sound.add(soundKey); diff --git a/game/states/play.js b/game/states/play.js index 15304d5..4d6080b 100644 --- a/game/states/play.js +++ b/game/states/play.js @@ -152,6 +152,12 @@ Play.prototype = { if (pad.isDown(Phaser.Gamepad.XBOX360_DPAD_DOWN) || pad.axis(Phaser.Gamepad.XBOX360_STICK_LEFT_Y) > 0.2) { this.movePlayer(player, 0, 1); } + + var poisonButton = pad.getButton(Phaser.Gamepad.XBOX360_A); + if (poisonButton.isDown && player.gamepadPoisonLastPressed < poisonButton.timeDown) { + player.gamepadPoisonLastPressed = poisonButton.timeDown; + this.togglePoisonPill(player); + } }, readLevelFile: function() { this.pills = this.game.add.group(); diff --git a/todo.md b/todo.md index 9234049..e5e45b0 100644 --- a/todo.md +++ b/todo.md @@ -1,7 +1,6 @@ TODO ==== -* Gamepad controls for poison pills * Add restrictions on movement into the center * Add tutorial / instructions page * Add reset / end game early mechanism -- cgit v1.2.3