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/prefabs/player.js | 1 + game/states/play.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'game') diff --git a/game/prefabs/player.js b/game/prefabs/player.js index fac3967..c7f0b94 100644 --- a/game/prefabs/player.js +++ b/game/prefabs/player.js @@ -17,6 +17,7 @@ var Player = function(game, x, y, key, frame, soundKey) { this.score = 0; this.maxScore = 1; this.isMyTurn = false; + this.canBeEaten = true; this.currentAnimation = { isMyTurn: true, 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