Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed displaying lives after death, added gameover music

  • Loading branch information...
commit 2c5423ec4f50ef6e461b3e49f65d2470b6d0692c 1 parent 546a3d2
@BlackScorp authored
View
3  assets/js/audio.js
@@ -66,6 +66,7 @@ Crafty.extend({
if(this.supported[ext]){
audio.src = url;
if (!Crafty.assets[url]) Crafty.assets[url] = audio;
+
}
}
@@ -98,7 +99,7 @@ Crafty.extend({
play:function(id,repeat,volume){
if(repeat == 0 || !Crafty.support.audio || !this.sounds[id]) return;
var s = this.sounds[id];
- s.obj.volume = Crafty.audio.volume || volume;
+ s.obj.volume = volume || Crafty.audio.volume ;
if(s.obj.currentTime) s.obj.currentTime = 0;
s.obj.play();
s.played ++;
View
2  assets/js/effects.js
@@ -12,7 +12,7 @@ Crafty.c("RandomExplosion",{
});
- Crafty.audio.play("explosion"+(rand %2));
+ Crafty.audio.play("explosion"+Crafty.math.randomInt(0,1),1,0.5);
}
});
Crafty.c("Damage",{
View
3  assets/js/levels.js
@@ -8,7 +8,6 @@ Crafty.scene("Loading",function(){
for(var i in Crafty.assets){
toLoad.push(i);
}
-
//Setup background image
Crafty.background("url("+game_path+"assets/img/loading.jpg) black");
@@ -41,6 +40,7 @@ Crafty.scene("Loading",function(){
},
function(e) {
var src = e.src ||"";
+ if(src=="ambient.ogg") console.log("yep")
//update progress
text.text("Loading "+src.substr(src.lastIndexOf('/') + 1).toLowerCase()+" Loaded: "+~~e.percent+"%");
bar.progressbar({
@@ -96,6 +96,7 @@ Crafty.scene("Level1",function(){
Crafty.stage.elem.style.backgroundPosition ="0px "+frame.frame+"px";
});
+
//Play background music and repeat
Crafty.audio.play("space",-1);
View
6 assets/js/player.js
@@ -198,11 +198,15 @@ Crafty.c("Player",{
y:this.y
});
this.lives--;
+ this.updateLives();
if(this.lives <= 0){
this.destroy();
this.infos.alert.show().text('Game Over!').effect('pulsate',500);
+ Crafty.audio.stop("space");
+ Crafty.audio.play("gameover",-1);
gameHooks.endGame(this.score);
- Crafty.pause();
+
+ // Crafty.pause();
}else{
this.reset();
}
View
1  assets/js/sounds.js
@@ -31,4 +31,5 @@ Crafty.audio.add("space",[
game_path + "media/music/through-space.ogg"
]);
+Crafty.audio.add("gameover", game_path + "media/music/ambient.ogg");
Crafty.audio.add("spaceship", game_path + "media/music/spaceship.mp3"); //Will work only Safari/IE
View
4 assets/js/weapons.js
@@ -30,7 +30,7 @@ Crafty.c("Weapon1",{
.attr({
dmg:1
});
- Crafty.audio.play("laser1");
+ Crafty.audio.play("laser1",1,0.8);
}
});
Crafty.c("Weapon2",{
@@ -44,6 +44,6 @@ Crafty.c("Weapon2",{
}).attr({
dmg:2
});
- Crafty.audio.play("laser2");
+ Crafty.audio.play("laser2",1,0.8);
}
});
View
BIN  media/music/ambient.ogg
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.