diff options
| author | Jan Tuomi <jan-sebastian.tuomi@aalto.fi> | 2016-12-14 20:13:11 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan-sebastian.tuomi@aalto.fi> | 2016-12-14 20:13:11 +0200 |
| commit | dbdfaafc447a4d09377619a7c824b87539453007 (patch) | |
| tree | ded742089a2ae0e94cb93265c766e69341a4cbba | |
| parent | 13c5dc317abe0fb4458e703f2ab9397a7c24c859 (diff) | |
Make Xmas fork
| -rw-r--r-- | index.html | 4 | ||||
| -rw-r--r-- | res/bg.mp3 | bin | 1667051 -> 5307608 bytes | |||
| -rw-r--r-- | res/bg.png | bin | 9692 -> 9336 bytes | |||
| -rw-r--r-- | res/int.png | bin | 6446 -> 106332 bytes | |||
| -rw-r--r-- | res/logo1.png | bin | 5785 -> 6843 bytes | |||
| -rw-r--r-- | res/logo2.png | bin | 5254 -> 5245 bytes | |||
| -rw-r--r-- | res/player.png | bin | 3542 -> 0 bytes | |||
| -rw-r--r-- | res/players/player1.png | bin | 0 -> 9772 bytes | |||
| -rw-r--r-- | res/players/player10.png | bin | 0 -> 10590 bytes | |||
| -rw-r--r-- | res/players/player11.png | bin | 0 -> 10426 bytes | |||
| -rw-r--r-- | res/players/player2.png | bin | 0 -> 10009 bytes | |||
| -rw-r--r-- | res/players/player3.png | bin | 0 -> 11298 bytes | |||
| -rw-r--r-- | res/players/player4.png | bin | 0 -> 9158 bytes | |||
| -rw-r--r-- | res/players/player5.png | bin | 0 -> 9723 bytes | |||
| -rw-r--r-- | res/players/player6.png | bin | 0 -> 8424 bytes | |||
| -rw-r--r-- | res/players/player7.png | bin | 0 -> 11034 bytes | |||
| -rw-r--r-- | res/players/player8.png | bin | 0 -> 8908 bytes | |||
| -rw-r--r-- | res/players/player9.png | bin | 0 -> 7346 bytes | |||
| -rw-r--r-- | src/engine.js | 18 | ||||
| -rw-r--r-- | src/gameobject.js | 10 | ||||
| -rw-r--r-- | src/objecttypes.js | 14 | ||||
| -rw-r--r-- | src/player.js | 7 | ||||
| -rw-r--r-- | src/settings.js | 3 |
23 files changed, 41 insertions, 15 deletions
@@ -2,7 +2,7 @@ <html> <head> <meta charset="UTF-8"> - <title>viivaintegraalipeli</title> + <title>Jouluinen hallituspeli</title> <style> body { position: fixed; @@ -30,4 +30,4 @@ <script type="text/javascript" src="src/platformer.js"></script> <center>Huom! 16.11. asianomistajan pyynnöstä grafiikkaa parannettu.<center> </body> -</html>
\ No newline at end of file +</html> Binary files differBinary files differdiff --git a/res/int.png b/res/int.png Binary files differindex 6eddea2..476723a 100644 --- a/res/int.png +++ b/res/int.png diff --git a/res/logo1.png b/res/logo1.png Binary files differindex 1630ac7..230db08 100644 --- a/res/logo1.png +++ b/res/logo1.png diff --git a/res/logo2.png b/res/logo2.png Binary files differindex 2e8b7b9..75ace39 100644 --- a/res/logo2.png +++ b/res/logo2.png diff --git a/res/player.png b/res/player.png Binary files differdeleted file mode 100644 index dd53460..0000000 --- a/res/player.png +++ /dev/null diff --git a/res/players/player1.png b/res/players/player1.png Binary files differnew file mode 100644 index 0000000..f49a795 --- /dev/null +++ b/res/players/player1.png diff --git a/res/players/player10.png b/res/players/player10.png Binary files differnew file mode 100644 index 0000000..37b462b --- /dev/null +++ b/res/players/player10.png diff --git a/res/players/player11.png b/res/players/player11.png Binary files differnew file mode 100644 index 0000000..5a59c72 --- /dev/null +++ b/res/players/player11.png diff --git a/res/players/player2.png b/res/players/player2.png Binary files differnew file mode 100644 index 0000000..62498a7 --- /dev/null +++ b/res/players/player2.png diff --git a/res/players/player3.png b/res/players/player3.png Binary files differnew file mode 100644 index 0000000..6c3d0cf --- /dev/null +++ b/res/players/player3.png diff --git a/res/players/player4.png b/res/players/player4.png Binary files differnew file mode 100644 index 0000000..b3e1dd9 --- /dev/null +++ b/res/players/player4.png diff --git a/res/players/player5.png b/res/players/player5.png Binary files differnew file mode 100644 index 0000000..90ca0c0 --- /dev/null +++ b/res/players/player5.png diff --git a/res/players/player6.png b/res/players/player6.png Binary files differnew file mode 100644 index 0000000..875cdc7 --- /dev/null +++ b/res/players/player6.png diff --git a/res/players/player7.png b/res/players/player7.png Binary files differnew file mode 100644 index 0000000..b4a5451 --- /dev/null +++ b/res/players/player7.png diff --git a/res/players/player8.png b/res/players/player8.png Binary files differnew file mode 100644 index 0000000..9f2f8ca --- /dev/null +++ b/res/players/player8.png diff --git a/res/players/player9.png b/res/players/player9.png Binary files differnew file mode 100644 index 0000000..5f2a8b9 --- /dev/null +++ b/res/players/player9.png 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(); diff --git a/src/gameobject.js b/src/gameobject.js index 0b50553..43218b1 100644 --- a/src/gameobject.js +++ b/src/gameobject.js @@ -1,12 +1,16 @@ function GameObject(texture) { - this.texture = PIXI.Texture.fromImage("res/" + texture + ".png"); - this.sprite = new PIXI.Sprite(this.texture); + this.updateTexture(texture); this.initPosition(); this.active = true; this.objectType = "gameobject"; } +GameObject.prototype.updateTexture = function(name) { + this.texture = PIXI.Texture.fromImage("res/" + name + ".png"); + this.sprite = new PIXI.Sprite(this.texture); +} + GameObject.prototype.initPosition = function() { this.sprite.anchor.x = 0.5; this.sprite.anchor.y = 0.5; @@ -17,4 +21,4 @@ GameObject.prototype.initPosition = function() { GameObject.prototype.update = function() { -}
\ No newline at end of file +} diff --git a/src/objecttypes.js b/src/objecttypes.js index d7b0df4..e9f69f0 100644 --- a/src/objecttypes.js +++ b/src/objecttypes.js @@ -53,15 +53,15 @@ scoreBg.beginFill(0xAAAAAA, 1.0); scoreBg.visible = false; // score display -var scoreText = new PIXI.Text("W", { font: '35px Arial', fill: 'black', align: 'left' }); +var scoreText = new PIXI.Text("W", { font: '35px Arial', fill: 'white', align: 'left' }); scoreText.visible = false; scoreText.update = function() { - this.text = "W = " + player.score + " J"; + this.text = "Tomia vältelty " + player.score + " tuntia"; } scoreText.moveToCorner = function() { - this.position.x = Settings.STAGE_WIDTH * 0.7; - this.position.y = Settings.STAGE_HEIGHT * 0.1; + this.position.x = Settings.STAGE_WIDTH * 0.5; + this.position.y = Settings.STAGE_HEIGHT * 0.05; } scoreText.moveToCenter = function() { @@ -71,14 +71,14 @@ scoreText.moveToCenter = function() { scoreText.moveToCorner(); // gameover screen title text -var gameOverText = new PIXI.Text("Nettovoiman tekemä työ:", { font: '35px Arial', fill: 'black', align: 'center' }); +var gameOverText = new PIXI.Text("Onneksi olkoon!", { font: '35px Arial', fill: 'black', align: 'center' }); gameOverText.visible = false; gameOverText.position.x = Settings.STAGE_WIDTH * 0.5 - gameOverText.width / 2;; gameOverText.position.y = Settings.STAGE_HEIGHT * 0.4 - gameOverText.height / 2;; // move the gameover bg box now that we now the width of the text var yDiff = scoreText.position.y - gameOverText.position.y + gameOverText.height; -scoreBg.drawRect(gameOverText.position.x - 10, gameOverText.position.y - 10, gameOverText.width + 20, -yDiff); +scoreBg.drawRect(Settings.STAGE_WIDTH * 0.2, gameOverText.position.y - 10, Settings.STAGE_WIDTH * 0.6, -yDiff); // integral sign function Integral(y) { @@ -104,4 +104,4 @@ Integral.prototype.initPosition = function() { Integral.prototype.update = function() { this.sprite.position.x += this.speed; -}
\ No newline at end of file +} diff --git a/src/player.js b/src/player.js index 64f00f8..e3a43b4 100644 --- a/src/player.js +++ b/src/player.js @@ -64,4 +64,9 @@ Player.prototype.update = function() { } } -var player = new Player("player");
\ No newline at end of file +Player.prototype.updateSprite = function(sprite) { + this.sprite = sprite; +} + +var number = Math.floor((Math.random() * Settings.PLAYER_COUNT) + 1); +var player = new Player("players/player" + number); diff --git a/src/settings.js b/src/settings.js index b515171..e0c8609 100644 --- a/src/settings.js +++ b/src/settings.js @@ -2,6 +2,7 @@ var Settings = function() {} Settings.STAGE_WIDTH = 800; Settings.STAGE_HEIGHT = 600; Settings.STAGE_BGCOLOR = 0xA0A0A0; +Settings.PLAYER_COUNT = 11; var lastTime = Date.now(); var dt = 0.0; @@ -12,4 +13,4 @@ function updateDeltaTime() { lastTime = current; dt = current - last; -}
\ No newline at end of file +} |
