summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2014-09-28 19:17:30 +0200
committerJustin Worthe <justin.worthe@gmail.com>2014-09-28 19:17:30 +0200
commit2c1fc87836f70feed5f60fdb79b89c4d30b9cacc (patch)
tree6ea8556c716c9a496dfb47639deb75184b78c31f
parentfdb805cfe9b0cbeea1ded7b06dc84ddbd2bc42c9 (diff)
Changed scale in HUD to relate better to game scaleHEADmain
-rw-r--r--assets/images/hud-bg.svg38
-rw-r--r--game/entities/hud.js71
-rw-r--r--game/states/play.js4
3 files changed, 54 insertions, 59 deletions
diff --git a/assets/images/hud-bg.svg b/assets/images/hud-bg.svg
index 346e215..99261d1 100644
--- a/assets/images/hud-bg.svg
+++ b/assets/images/hud-bg.svg
@@ -9,16 +9,15 @@
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="400"
- height="1100"
-
+ width="800"
+ height="2200"
version="1.1"
inkscape:version="0.48.4 r9939"
- sodipodi:docname="hud-bg.svg">
+ sodipodi:docname="hud-bg.svg"
+ id="svg2997">
<defs
- />
+ id="defs2999" />
<sodipodi:namedview
-
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
@@ -26,38 +25,39 @@
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="188.15199"
- inkscape:cy="919.42921"
+ inkscape:cy="2174.4239"
inkscape:document-units="px"
- inkscape:current-layer="layer1"
+ inkscape:current-layer="g3005"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
- inkscape:window-maximized="1" />
+ inkscape:window-maximized="1"
+ id="namedview3001" />
<metadata
- >
+ id="metadata3003">
<rdf:RDF>
<cc:Work
rdf:about="">
<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>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
-
- transform="translate(0,47.637817)">
+ transform="translate(0,1147.6378)"
+ id="g3005">
<rect
- style="fill:#000000;fill-opacity:1;stroke:#0000ff;stroke-width:10;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
-
- width="390"
- height="1090"
- x="5"
- y="-42.637817" />
+ style="fill:#000000;fill-opacity:1;stroke:#0000ff;stroke-width:20;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ width="780"
+ height="2180"
+ x="10"
+ y="-1137.6378"
+ id="rect3007" />
</g>
</svg>
diff --git a/game/entities/hud.js b/game/entities/hud.js
index 43e7a21..bc4b466 100644
--- a/game/entities/hud.js
+++ b/game/entities/hud.js
@@ -1,48 +1,47 @@
'use strict';
var Hud = function(game, player, x, y, scorefontKey, keyboardSpriteKey) {
- Phaser.Group.call(this, game);
- this.x = x;
- this.y = y;
- this.player = player;
- this.scale = {x: 0.02, y: 0.02};
-
- this.background = new Phaser.Sprite(this.game, 0, 0, 'hud-bg');
- this.add(this.background);
- this.scoreText = new Phaser.BitmapText(this.game, 172, 10, scorefontKey, '0', 100);
- this.add(this.scoreText);
-
- this.poisonIndicator = new Phaser.Sprite(this.game, 200, 150, 'poison-pill');
- this.poisonIndicator.anchor = {x:0.5, y:0.5};
- this.add(this.poisonIndicator);
-
- this.controllerDiagram = new Phaser.Sprite(this.game, 0, 300, 'controller-diagram');
- this.controllerDiagram.scale = {x: 0.5, y: 0.5};
- this.add(this.controllerDiagram);
-
- this.keyboardControls = new Phaser.Sprite(this.game, 0, 600, keyboardSpriteKey);
- this.keyboardControls.scale = {x: 0.5, y: 0.5};
- this.add(this.keyboardControls);
-
- this.currentScore = 0;
+ Phaser.Group.call(this, game);
+ this.x = x;
+ this.y = y;
+ this.player = player;
+ this.scale = {x: 0.01, y: 0.01};
+
+ this.background = new Phaser.Sprite(this.game, 0, 0, 'hud-bg');
+ this.add(this.background);
+ this.scoreText = new Phaser.BitmapText(this.game, 344, 20, scorefontKey, '0', 200);
+ this.add(this.scoreText);
+
+ this.poisonIndicator = new Phaser.Sprite(this.game, 400, 300, 'poison-pill');
+ this.poisonIndicator.scale = {x: 2, y: 2}; //bigger than an actual poison pill
+ this.poisonIndicator.anchor = {x: 0.5, y: 0.5};
+ this.add(this.poisonIndicator);
+
+ this.controllerDiagram = new Phaser.Sprite(this.game, 0, 600, 'controller-diagram');
+ this.add(this.controllerDiagram);
+
+ this.keyboardControls = new Phaser.Sprite(this.game, 0, 1200, keyboardSpriteKey);
+ this.add(this.keyboardControls);
+
+ this.currentScore = 0;
};
Hud.prototype = Object.create(Phaser.Group.prototype);
Hud.prototype.constructor = Hud;
Hud.prototype.update = function() {
- if (this.currentScore !== this.player.score) {
- this.currentScore = this.player.score;
- this.scoreText.setText(this.player.score+'');
-
- var numberOfDigits = Math.floor(Math.log(this.currentScore)/Math.log(10))+1;
- this.scoreText.x = 200 - numberOfDigits*30;
- }
-
- if (this.poisonIndicator && !this.player.hasPoisonPill) {
- this.poisonIndicator.destroy();
- this.poisonIndicator = null;
- }
+ if (this.currentScore !== this.player.score) {
+ this.currentScore = this.player.score;
+ this.scoreText.setText(this.player.score+'');
+
+ var numberOfDigits = Math.floor(Math.log(this.currentScore)/Math.log(10))+1;
+ this.scoreText.x = 400 - numberOfDigits*60;
+ }
+
+ if (this.poisonIndicator && !this.player.hasPoisonPill) {
+ this.poisonIndicator.destroy();
+ this.poisonIndicator = null;
+ }
};
module.exports = Hud;
diff --git a/game/states/play.js b/game/states/play.js
index cb1edf7..6699ef0 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -59,8 +59,6 @@ Play.prototype = {
return Math.max(currentMax, nextRow.trim().length);
}, 0);
-
-
for (var y=0; y<splitRows.length; y++) {
for (var x=0; x<splitRows[y].length; x++) {
switch(splitRows[y][x]) {
@@ -88,13 +86,11 @@ Play.prototype = {
}
}
}
-
var totalScore = this.pills.children.reduce(function(score, nextPill) {
return score + nextPill.score;
}, 0);
-
this.players.forEach(function(player) {
player.maxScore = totalScore;
}, this);