summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-09-02 07:29:19 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-09-02 07:29:19 +0200
commit0afb9206527dfae6793e5e569bd9084018048844 (patch)
tree5130b1365c709b0be7c31a8574c030c99788493c
parent4b108a35a580d4805553ad7d3075e9fb4ec0f48b (diff)
Handled players both eating poison together
-rw-r--r--game/prefabs/player.js1
-rw-r--r--game/states/play.js5
-rw-r--r--todo.md1
3 files changed, 5 insertions, 2 deletions
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<this.players.children.length; ++i) {
this.players.children[i].isMyTurn = (i === this.playerTurn);
+ this.players.children[i].canBeEaten = true;
}
},
setVictoryText: function(newText, winnerLetter) {
diff --git a/todo.md b/todo.md
index cefb9ff..3c51b36 100644
--- a/todo.md
+++ b/todo.md
@@ -3,7 +3,6 @@ TODO
* Add restrictions on movement into the center
4. Cannot drop poison pill in the middle
-* Play sound effect only once when both players are in the respawn area
* Add tutorial / instructions page
* Add reset / end game early mechanism
* Regenerate fonts with new colours