aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine.js
diff options
context:
space:
mode:
authorJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-12-14 20:13:11 +0200
committerJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-12-14 20:13:11 +0200
commitdbdfaafc447a4d09377619a7c824b87539453007 (patch)
treeded742089a2ae0e94cb93265c766e69341a4cbba /src/engine.js
parent13c5dc317abe0fb4458e703f2ab9397a7c24c859 (diff)
Make Xmas fork
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();