From 0afb9206527dfae6793e5e569bd9084018048844 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Tue, 2 Sep 2014 07:29:19 +0200 Subject: Handled players both eating poison together --- game/states/play.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'game/states/play.js') diff --git a/game/states/play.js b/game/states/play.js index c81d978..37dabb4 100644 --- a/game/states/play.js +++ b/game/states/play.js @@ -29,7 +29,8 @@ Play.prototype = { this.checkForPlayerPillCollisions(); this.checkForPlayerPoisonPillCollisions(); - if (Phaser.Rectangle.intersects(this.playerA.getBounds(), this.playerB.getBounds())) { + if (this.playerA.canBeEaten && this.playerB.canBeEayen && + Phaser.Rectangle.intersects(this.playerA.getBounds(), this.playerB.getBounds())) { this.playerPlayerCollision(this.playerA, this.playerB); } @@ -372,6 +373,7 @@ Play.prototype = { else { eatenPlayer.teleport(this.respawnX, this.respawnY); } + eatenPlayer.canBeEaten = false; eatenPlayer.respawnSound.play(); }, togglePlayerTurn: function() { @@ -381,6 +383,7 @@ Play.prototype = { this.playerTurn = newPlayerTurn; for (var i=0; i