aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine.js')
-rw-r--r--src/engine.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/engine.js b/src/engine.js
index 30d7d7a..b75886a 100644
--- a/src/engine.js
+++ b/src/engine.js
@@ -56,8 +56,19 @@ Engine.prototype.makeStageClickable = function() {
this.clickLayer.touchstart = this.clickLayer.mousedown = this.buttonPressed.bind(this);
}
+Engine.prototype.randomizePlayer = function() {
+ this.removeSprite(player.sprite);
+ var number = Math.floor((Math.random() * Settings.PLAYER_COUNT) + 1);
+ var newTexture = PIXI.Texture.fromImage("res/players/player" + number + ".png");
+ player.sprite = new PIXI.Sprite(newTexture);
+ this.unitsContainer.addChild(player.sprite);
+}
+
Engine.prototype.activateMenu = function() {
this.state = MENU;
+
+ this.randomizePlayer();
+
player.score = 0
console.log("changed to menu!");
logo1.sprite.visible = true;
@@ -97,6 +108,10 @@ Engine.prototype.activateGameOver = function() {
this.sound.play("explosion")
}
+Engine.prototype.removeSprite = function(sprite) {
+ this.unitsContainer.removeChild(sprite);
+}
+
Engine.prototype.removeIntegral = function(integral) {
var i = this.gameObjectList.indexOf(integral);
this.gameObjectList.splice(i, 1);
@@ -198,6 +213,7 @@ Engine.prototype.setupGameObjects = function() {
// add player to gameobjectlist
this.gameObjectList = [];
+
this.unitsContainer.addChild(player.sprite);
this.menuContainer.addChild(logo1.sprite);
this.menuContainer.addChild(logo2.sprite);
@@ -214,4 +230,4 @@ Engine.prototype.setupGameObjects = function() {
this.stage.updateLayersOrder();
}
-var engine = new Engine(); \ No newline at end of file
+var engine = new Engine();