summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-09-01 08:11:57 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-09-01 08:11:57 +0200
commit4b108a35a580d4805553ad7d3075e9fb4ec0f48b (patch)
treef90103b9880ba013088f0e7987a342c79792ae95 /game
parentb127c30374c2dcc283e37fa3038b8de2316cad73 (diff)
Prevented eating opponent when leaving respawn spot
Diffstat (limited to 'game')
-rw-r--r--game/states/play.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/game/states/play.js b/game/states/play.js
index 617176d..c81d978 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -275,14 +275,26 @@ Play.prototype = {
var newX = player.x + deltaX;
var newY = player.y + deltaY;
var placePoisonPill = player.hasPoisonPill && player.poisonPillActive;
+
+ //cannot move into walls, when it isn't your turn, or when you're already moving
if (this.checkMap(newX, newY) || !player.isMyTurn || player.moving) {
return;
}
- if (Math.abs(newX-this.respawnX)<=1 && Math.abs(newY-this.respawnY)<=1 && (
- Math.abs(newX-this.respawnX)<Math.abs(player.x-this.respawnX) ||
- Math.abs(newY-this.respawnY)<Math.abs(player.y-this.respawnY))) {
- return;
+ if (Math.abs(newX-this.respawnX)<=1 && Math.abs(newY-this.respawnY)<=1) {
+ //cannot move into respawn area
+ if (Math.abs(newX-this.respawnX)<Math.abs(player.x-this.respawnX) ||
+ Math.abs(newY-this.respawnY)<Math.abs(player.y-this.respawnY)) {
+ return;
+ }
+
+ //cannot eat opponent when leaving respawn block
+ for (var playerIndex=0; playerIndex<this.players.children.length; ++playerIndex) {
+ var opponent = this.players.children[playerIndex];
+ if (Math.abs(newX-opponent.x)<0.1 && Math.abs(newY-opponent.y)<0.1) {
+ return;
+ }
+ }
}
var posionPillX = player.x;