From 5c848fb46d930241a61feb60fc41b5bb5551d32e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Mon, 8 Sep 2014 13:33:19 +0200 Subject: Added HUD with controller diagram and score --- game/states/play.js | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'game/states/play.js') diff --git a/game/states/play.js b/game/states/play.js index 26242b3..cf4bf62 100644 --- a/game/states/play.js +++ b/game/states/play.js @@ -5,6 +5,7 @@ var Pill = require('../prefabs/pill'); var BonusPill = require('../prefabs/bonusPill'); var Wall = require('../prefabs/wall'); var PoisonPill = require('../prefabs/poisonPill'); +var Hud = require('../prefabs/hud'); function Play() {} @@ -15,15 +16,18 @@ Play.prototype = { this.readLevelFile(); this.world.scale = {x:50, y:50}; - this.world.bounds = {x: -25, y:-25, width: this.game.width, height: this.game.height}; + this.world.bounds = {x: -425, y:-25, width: this.game.width, height: this.game.height}; this.world.camera.setBoundsToWorld(); this.setupPlayerControls(); - this.playerAScoreText = this.game.add.bitmapText(-0.1, -0.4, 'spaced-scorefont-a','0',2); - this.playerBScoreText = this.game.add.bitmapText(this.world.width/this.world.scale.x - 4.5, -0.4, 'spaced-scorefont-b','0',2); - this.gameWon = false; + + this.hudA = new Hud(this.game, this.playerA, this.gameWidth-0.5, -0.5, 'spaced-scorefont-a'); + this.hudB = new Hud(this.game, this.playerB, -8.5, -0.5, 'spaced-scorefont-b'); + //this.game.add.existing(this.hudA); + //this.game.add.existing(this.hudB); + }, update: function() { this.checkForPlayerPillCollisions(); @@ -170,9 +174,9 @@ Play.prototype = { var levelText = this.game.cache.getText('level'); var splitRows = levelText.split('\n'); - for (var x=0; x