From 8d9e59e1d3addfcbeab2a00796e5e2da3ff0a608 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Wed, 27 Aug 2014 08:12:55 +0200 Subject: Added visual indication of player ready to place poison pill --- assets/images/player-a-spritesheet.svg | 34 +++++++++++++++++++++++++++------- assets/images/player-b-spritesheet.svg | 30 +++++++++++++++++++++++++----- game/prefabs/player.js | 33 +++++++++++++++++++++++++++++---- game/states/play.js | 7 ++++--- todo.md | 1 - 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"> image/svg+xml - + @@ -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)" /> + + 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"> image/svg+xml - + @@ -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)" /> + + 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 -- cgit v1.2.3