Permalink
Browse files

Bug 22 - Added sound effects for various events.

  • Loading branch information...
1 parent 2c1dbe3 commit 0bc363b37d32ed05a08dc783fcaa1c409d93a44b @jonoxia committed Nov 2, 2011
File renamed without changes.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -15,4 +15,11 @@
<span style="display:none;" id="avatarURL">${avatarURL}</span>
<span id="debug"></span>
<audio id="bgm" preload="auto" autobuffer="true" loop="true"></audio>
+ <audio id="death-sfx" preload="auto" autobuffer="true" src="sfx/death.ogg"></audio>
+ <audio id="victory-sfx" preload="auto" autobuffer="true" src="sfx/victory.ogg"></audio>
+ <audio id="jump-sfx" preload="auto" autobuffer="true" src="sfx/jump.ogg"></audio>
+ <audio id="bonk-sfx" preload="auto" autobuffer="true" src="sfx/donk.ogg"></audio>
+ <audio id="crunch-sfx" preload="auto" autobuffer="true" src="sfx/crunch.ogg"></audio>
+ <audio id="kaching-sfx" preload="auto" autobuffer="true" src="sfx/kaching.ogg"></audio>
+
</body></html>
View
@@ -9,3 +9,9 @@ function gup( name )
else
return unescape(results[1]);
}
+
+function playSfx(tagId) {
+ filename = $("#" + tagId).attr("src");
+ var snd = new Audio(filename);
+ snd.play();
+}
View
@@ -96,16 +96,19 @@ Mob.prototype = {
this.vx = 0;
this.left = intercept.x - this.width;
this.top = intercept.y;
+ playSfx("bonk-sfx")
break;
case "right":
this.vx = 0;
this.left = intercept.x;
this.top = intercept.y;
+ playSfx("bonk-sfx")
break;
case "bottom":
this.vy = 0;
this.left = intercept.x;
this.top = intercept.y;
+ playSfx("bonk-sfx")
break;
}
},
@@ -130,6 +133,7 @@ Mob.prototype = {
// my head.
if (this.onGround() && !this.jumping &&
! TheWorld.touchingPlatform(this, "top")) {
+ playSfx("jump-sfx");
this.vy -= this.jumpPower;
this.jumping = true; // to make jump idempotent, fix bug 2
}
@@ -240,6 +244,7 @@ Enemy.prototype = {
this.die();
// TODO death animation?
mob.vy = -10; // bounce
+ playSfx("crunch-sfx");
} else {
mob.die();
}
View
@@ -93,6 +93,7 @@ $(document).ready(function() {
if (player.intersecting(TheWorld.goalArea)) {
$("#output").html("A WINRAR IS YOU!");
$("#bgm")[0].pause();
+ playSfx("victory-sfx");
// TODO play victory sound effects!
window.clearInterval(heartbeat);
$.ajax({type: "POST",
@@ -114,13 +115,13 @@ $(document).ready(function() {
$("#output").html("YOU'RE MONSTER CHOW (reload to play again)");
window.clearInterval(heartbeat);
$("#bgm")[0].pause();
- // TODO play death sound effects!
+ playSfx("death-sfx");
}
if (player.top > bottomLimit) {
$("#output").html("GRAVITY IS A HARSH MISTRESS (reload to play again)");
window.clearInterval(heartbeat);
$("#bgm")[0].pause();
- // TODO play death sound effects
+ playSfx("death-sfx");
}
}, 100);
});
View
@@ -657,6 +657,7 @@ PointlessTrinket.prototype = {
}
},
onCollect: function(player) {
+ playSfx("kaching-sfx");
if (player.numTrinkets == 0) {
player.numTrinkets = 1;
} else {

0 comments on commit 0bc363b

Please sign in to comment.