summaryrefslogtreecommitdiff
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
parentb127c30374c2dcc283e37fa3038b8de2316cad73 (diff)
Prevented eating opponent when leaving respawn spot
-rw-r--r--game/states/play.js20
-rw-r--r--todo.md3
2 files changed, 17 insertions, 6 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;
diff --git a/todo.md b/todo.md
index 93f09d7..cefb9ff 100644
--- a/todo.md
+++ b/todo.md
@@ -2,10 +2,9 @@ TODO
====
* Add restrictions on movement into the center
- 3. Cannot move out of center and eat opponent
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
-* Add reading controls from file
* Refine orientation controls