Commit 126c72f5 authored by Pablo R. Mier's avatar Pablo R. Mier

Music (thanks to Constantino Antonio García Fernández for composing the music) and sfx added.

parent 4758d72e
......@@ -64,7 +64,23 @@ invadersApp.Game.prototype = {
// Initialize basic physics
this.game.physics.startSystem(Phaser.Physics.ARCADE);
// Load mainMusic assets
this.gameOverMusic = this.add.audio('gameOverMusic');
// FX sounds (from ...)
this.fx = this.game.add.audio('sfx');
this.fx.allowMultiple = true;
this.fx.addMarker('alien_death', 1, 1.0);
this.fx.addMarker('hit', 3, 0.5);
this.fx.addMarker('escape', 4, 3.2);
this.fx.addMarker('meow', 8, 0.5);
this.fx.addMarker('numkey', 9, 0.1);
this.fx.addMarker('ping', 10, 1.0);
this.fx.addMarker('death', 12, 4.2);
this.fx.addMarker('shot', 17, 1.0);
this.fx.addMarker('squit', 19, 0.3);
// Group of invaders
this.objects.invaders = this.add.group();
......@@ -124,6 +140,7 @@ invadersApp.Game.prototype = {
var living = that.objects.invaders.countLiving();
if (living > MIN_INVADERS) {
invader.destroy();
that.fx.play('alien_death');
that.updateCounter();
}
if (living == MIN_INVADERS + 1) {
......@@ -140,7 +157,7 @@ invadersApp.Game.prototype = {
quitGame: function (pointer) {
// TODO: Stop music, delete sprites, purge caches, free resources...
// TODO: Stop mainMusic, delete sprites, purge caches, free resources...
// Then let's go back to the main menu.
this.state.start('MainMenu');
......@@ -160,6 +177,8 @@ invadersApp.Game.prototype = {
gameOver: function () {
invadersApp.utils.addText(this, this.game.width / 2, this.game.height / 2, 'GAME OVER!', 5);
this.gameState = invadersApp.GameState.GAME_OVER;
//invadersApp.MainMenu.mainMusic.stop();
this.gameOverMusic.play('', 0, 1, true, true);
},
updateEvolution: function () {
......
invadersApp.MainMenu = function (game) {
this.music = null;
this.mainMusic = null;
this.playButton = null;
};
......@@ -9,8 +9,8 @@ invadersApp.MainMenu.prototype = {
create: function () {
this.music = this.add.audio('titleMusic');
//this.music.play('', 0, 1, true, true);
this.mainMusic = this.add.audio('mainMusic');
//this.mainMusic.play('', 0, 1, true, true);
var textTop = invadersApp.utils.addText(this, this.game.width / 2, 50, 'CITIUS PROUDLY PRESENTS:' , 2);
......@@ -39,7 +39,11 @@ invadersApp.MainMenu.prototype = {
//var titleText = this.add.bitmapText(this.game.width / 2, 50, 'minecraftia', 'CiTIUS INVADERS', 50);
//titleText.anchor.x = 0.5;
var textPressStart = invadersApp.utils.addText(this, this.game.width / 2, titleYPos + 200, 'PRESS START', 2);
var textIES = invadersApp.utils.addText(this, this.game.width / 2, titleYPos + 50, 'A GAME FOR IES ROSALIA DE CASTRO', 1);
textIES.img.visible = false;
var textPressStart = invadersApp.utils.addText(this, this.game.width / 2, titleYPos + 200, 'PRESS ENTER', 2);
textPressStart.img.visible = false;
//var startEntry = this.addMenuEntry('START GAME', titleYPos + 160, this.startGame);
......@@ -55,8 +59,8 @@ invadersApp.MainMenu.prototype = {
tweenPresents.chain(tweenTitle);
tweenPresents.onComplete.add(function () {
// Play music
this.music.play('', 0, 1, true, true);
// Play mainMusic
this.mainMusic.play('', 0, 1, true, true);
}, this);
tweenTitle.onComplete.add(function () {
......@@ -64,13 +68,14 @@ invadersApp.MainMenu.prototype = {
logo.visible = true;
textCopyright.img.visible = true;
textPressStart.img.visible = true;
textIES.img.visible = true;
// Start blinking event for 'PRESS START'
this.game.time.events.loop(Phaser.Timer.HALF, function () {
textPressStart.img.visible = !textPressStart.img.visible;
}, this);
//this.music.play('', 0, 1, true, true);
//this.mainMusic.play('', 0, 1, true, true);
}, this);
......@@ -87,7 +92,7 @@ invadersApp.MainMenu.prototype = {
},
startGame: function (pointer) {
this.music.stop();
this.mainMusic.stop();
this.state.start('Game');
}
......
......@@ -34,7 +34,9 @@ invadersApp.Preloader.prototype = {
this.load.image('titlepage', 'assets/title.png');
//this.load.atlas('playButton', 'images/play_button.png', 'images/play_button.json');
this.load.audio('titleMusic', ['assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);
this.load.audio('gameOverMusic', ['assets/audio/invaders_gameover.ogg']);
this.load.audio('mainMusic', ['assets/audio/invaders_mainloop.ogg']);
this.load.audio('sfx', 'assets/audio/fx_mixdown.ogg');
// + lots of other required assets here
this.load.image('nao', 'assets/nao.png');
......@@ -50,7 +52,7 @@ invadersApp.Preloader.prototype = {
create: function () {
// Once the load has finished we disable the crop because we're going to sit in the update loop for a short while as the music decodes
// Once the load has finished we disable the crop because we're going to sit in the update loop for a short while as the mainMusic decodes
this.preloadBar.cropEnabled = false;
},
......
......@@ -79,6 +79,7 @@ invadersApp.Player.prototype.update = function () {
bullet.reset(xpos, this.y - 20);
//bullet.body.velocity.y = -(1000 + aliveInvaders * 15);
bullet.body.velocity.y = -2000;
this.ctx.fx.play('shot');
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment