diff options
author | Justin Worthe <justin.worthe@entelect.co.za> | 2014-05-14 14:30:24 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@entelect.co.za> | 2014-05-14 14:30:24 +0200 |
commit | a4130986757165fcf72056d97a1608c41bd6abb4 (patch) | |
tree | e9f5ced717b3134d5be5bf4679adb2367d62e5b9 | |
parent | cbcb7ac6b9fde4586cd62ca961f97974d302f0b7 (diff) |
Added condition for game ending
re #9
-rw-r--r-- | game/states/play.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/game/states/play.js b/game/states/play.js index e05a65f..49c6cca 100644 --- a/game/states/play.js +++ b/game/states/play.js @@ -46,6 +46,20 @@ Play.prototype = { }, update: function() { this.game.physics.arcade.overlap(this.players, this.pills, this.playerPillCollision, null, this); + + if (this.pills.total === 0) { + + if (this.playerA.score > this.playerB.score) { + console.log("PLAYER A WINS!"); + } + else if (this.playerA.score < this.playerB.score) { + console.log("PLAYER B WINS!"); + } + else { + console.log("THIS GAME WAS A DRAW!") + } + this.game.state.start('play'); + } }, createWalls: function() { this.walls = this.game.add.group(); |