summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-08-27 08:12:55 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-08-27 08:12:55 +0200
commit8d9e59e1d3addfcbeab2a00796e5e2da3ff0a608 (patch)
tree98ef0cf23fe11a1cf0609896cbf87fa1409d902f
parentd188dc926f956a856f391889bfa135de08ba4027 (diff)
Added visual indication of player ready to place poison pill
-rw-r--r--assets/images/player-a-spritesheet.svg34
-rw-r--r--assets/images/player-b-spritesheet.svg30
-rw-r--r--game/prefabs/player.js33
-rw-r--r--game/states/play.js7
-rw-r--r--todo.md1
5 files changed, 85 insertions, 20 deletions
diff --git a/assets/images/player-a-spritesheet.svg b/assets/images/player-a-spritesheet.svg
index bc2ad19..6e4a3e8 100644
--- a/assets/images/player-a-spritesheet.svg
+++ b/assets/images/player-a-spritesheet.svg
@@ -9,12 +9,12 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="200"
+ width="400"
height="100"
id="svg2"
version="1.1"
inkscape:version="0.48.4 r9939"
- sodipodi:docname="player-a.svg">
+ sodipodi:docname="player-a-spritesheet.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -24,9 +24,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="5.6"
- inkscape:cx="117.44598"
- inkscape:cy="39.526154"
+ inkscape:zoom="2.8"
+ inkscape:cx="169.97246"
+ inkscape:cy="33.130835"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
@@ -43,7 +43,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -60,7 +60,7 @@
sodipodi:cy="50"
sodipodi:rx="48"
sodipodi:ry="48"
- d="M 98,50 C 98,76.509668 76.509668,98 50,98 23.490332,98 2,76.509668 2,50 2,23.490332 23.490332,2 50,2 76.509668,2 98,23.490332 98,50 z"
+ d="M 98,50 A 48,48 0 1 1 2,50 48,48 0 1 1 98,50 z"
transform="translate(0,952.36218)" />
<path
sodipodi:type="arc"
@@ -72,5 +72,25 @@
sodipodi:ry="48"
d="M 98,50 A 48,48 0 1 1 2,50 48,48 0 1 1 98,50 z"
transform="translate(100,952.36218)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff4500;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="path2985-0"
+ sodipodi:cx="50"
+ sodipodi:cy="50"
+ sodipodi:rx="48"
+ sodipodi:ry="48"
+ d="M 98,50 A 48,48 0 1 1 2,50 48,48 0 1 1 98,50 z"
+ transform="translate(200,952.36218)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#992200;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="path2985-1-4"
+ sodipodi:cx="50"
+ sodipodi:cy="50"
+ sodipodi:rx="48"
+ sodipodi:ry="48"
+ d="M 98,50 A 48,48 0 1 1 2,50 48,48 0 1 1 98,50 z"
+ transform="translate(300,952.36218)" />
</g>
</svg>
diff --git a/assets/images/player-b-spritesheet.svg b/assets/images/player-b-spritesheet.svg
index 33cf5a2..c33ddcf 100644
--- a/assets/images/player-b-spritesheet.svg
+++ b/assets/images/player-b-spritesheet.svg
@@ -9,12 +9,12 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="200"
+ width="400"
height="100"
id="svg2"
version="1.1"
inkscape:version="0.48.4 r9939"
- sodipodi:docname="player-b.svg">
+ sodipodi:docname="player-b-spritesheet.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -25,7 +25,7 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
- inkscape:cx="13.561425"
+ inkscape:cx="214.4155"
inkscape:cy="12.003943"
inkscape:document-units="px"
inkscape:current-layer="layer1"
@@ -43,7 +43,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -60,7 +60,7 @@
sodipodi:cy="50"
sodipodi:rx="48"
sodipodi:ry="48"
- d="M 98,50 C 98,76.509668 76.509668,98 50,98 23.490332,98 2,76.509668 2,50 2,23.490332 23.490332,2 50,2 76.509668,2 98,23.490332 98,50 z"
+ d="M 98,50 A 48,48 0 1 1 2,50 48,48 0 1 1 98,50 z"
transform="translate(0,952.36218)" />
<path
sodipodi:type="arc"
@@ -72,5 +72,25 @@
sodipodi:ry="48"
d="M 98,50 A 48,48 0 1 1 2,50 48,48 0 1 1 98,50 z"
transform="translate(100,952.36218)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="path2985-1"
+ sodipodi:cx="50"
+ sodipodi:cy="50"
+ sodipodi:rx="48"
+ sodipodi:ry="48"
+ d="M 98,50 A 48,48 0 1 1 2,50 48,48 0 1 1 98,50 z"
+ transform="translate(200,952.36218)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#999900;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="path2985-7-9"
+ sodipodi:cx="50"
+ sodipodi:cy="50"
+ sodipodi:rx="48"
+ sodipodi:ry="48"
+ d="M 98,50 A 48,48 0 1 1 2,50 48,48 0 1 1 98,50 z"
+ transform="translate(300,952.36218)" />
</g>
</svg>
diff --git a/game/prefabs/player.js b/game/prefabs/player.js
index e1cdc60..f0a6b65 100644
--- a/game/prefabs/player.js
+++ b/game/prefabs/player.js
@@ -6,6 +6,8 @@ var Player = function(game, x, y, key, frame, soundKey) {
Phaser.Sprite.call(this, game, x, y, key, frame);
this.animations.add('active', [0]);
this.animations.add('waiting', [1]);
+ this.animations.add('activePoison', [2]);
+ this.animations.add('waitingPoison', [3]);
this.baseKey = key;
this.moving = false;
@@ -15,7 +17,11 @@ var Player = function(game, x, y, key, frame, soundKey) {
this.score = 0;
this.maxScore = 1;
this.isMyTurn = false;
- this.animIsMyTurn = true;
+
+ this.currentAnimation = {
+ isMyTurn: true,
+ poisonPillActive: false
+ }
this.hasPoisonPill = true;
this.poisonPillActive = false;
@@ -42,9 +48,28 @@ Player.prototype = Object.create(Phaser.Sprite.prototype);
Player.prototype.constructor = Player;
Player.prototype.update = function() {
- if (this.isMyTurn !== this.animIsMyTurn) {
- this.animIsMyTurn = this.isMyTurn;
- this.play(this.animIsMyTurn ? 'active' : 'waiting');
+ if (this.isMyTurn !== this.currentAnimation.isMyTurn || this.poisonPillActive !== this.currentAnimation.poisonPillActive) {
+ this.currentAnimation.isMyTurn = this.isMyTurn;
+ this.currentAnimation.poisonPillActive = this.poisonPillActive;
+
+ var animation;
+ if (!this.currentAnimation.isMyTurn) {
+ if (!this.currentAnimation.poisonPillActive) {
+ animation = 'waiting';
+ }
+ else {
+ animation = 'waitingPoison'
+ }
+ }
+ else {
+ if (!this.currentAnimation.poisonPillActive) {
+ animation = 'active';
+ }
+ else {
+ animation = 'activePoison'
+ }
+ }
+ this.play(animation);
}
};
diff --git a/game/states/play.js b/game/states/play.js
index ec0ddae..15304d5 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -262,6 +262,9 @@ Play.prototype = {
var newX = player.x + deltaX;
var newY = player.y + deltaY;
var placePoisonPill = player.hasPoisonPill && player.poisonPillActive;
+ if (this.checkMap(newX, newY) || !player.isMyTurn || player.moving) {
+ return;
+ }
var posionPillX = player.x;
var posionPillY = player.y;
@@ -269,9 +272,7 @@ Play.prototype = {
player.hasPoisonPill = false;
}
- if (this.checkMap(newX, newY) || !player.isMyTurn || player.moving) {
- return;
- }
+
var intermediateX = newX;
var teleportX = newX;
diff --git a/todo.md b/todo.md
index 08c8d98..e5e45b0 100644
--- a/todo.md
+++ b/todo.md
@@ -1,7 +1,6 @@
TODO
====
-* Add visual representation for players ready to drop poison pills
* Add restrictions on movement into the center
* Add tutorial / instructions page
* Add reset / end game early mechanism