Skip to content
This repository
Browse code

Bug 22 - Added sound effects for various events.

  • Loading branch information...
commit 0bc363b37d32ed05a08dc783fcaa1c409d93a44b 1 parent 2c1dbe3
jonoxia authored
0  Bach.ogg → sfx/Bach.ogg
File renamed without changes
BIN  sfx/crunch.ogg
Binary file not shown
BIN  sfx/death.ogg
Binary file not shown
BIN  sfx/donk.ogg
Binary file not shown
BIN  sfx/jump.ogg
Binary file not shown
BIN  sfx/kaching.ogg
Binary file not shown
BIN  sfx/victory.ogg
Binary file not shown
7 templates/play.html
@@ -15,4 +15,11 @@
15 15 <span style="display:none;" id="avatarURL">${avatarURL}</span>
16 16 <span id="debug"></span>
17 17 <audio id="bgm" preload="auto" autobuffer="true" loop="true"></audio>
  18 + <audio id="death-sfx" preload="auto" autobuffer="true" src="sfx/death.ogg"></audio>
  19 + <audio id="victory-sfx" preload="auto" autobuffer="true" src="sfx/victory.ogg"></audio>
  20 + <audio id="jump-sfx" preload="auto" autobuffer="true" src="sfx/jump.ogg"></audio>
  21 + <audio id="bonk-sfx" preload="auto" autobuffer="true" src="sfx/donk.ogg"></audio>
  22 + <audio id="crunch-sfx" preload="auto" autobuffer="true" src="sfx/crunch.ogg"></audio>
  23 + <audio id="kaching-sfx" preload="auto" autobuffer="true" src="sfx/kaching.ogg"></audio>
  24 +
18 25 </body></html>
6 webclient_utils.js
@@ -9,3 +9,9 @@ function gup( name )
9 9 else
10 10 return unescape(results[1]);
11 11 }
  12 +
  13 +function playSfx(tagId) {
  14 + filename = $("#" + tagId).attr("src");
  15 + var snd = new Audio(filename);
  16 + snd.play();
  17 +}
5 webrunner-mobs.js
@@ -96,16 +96,19 @@ Mob.prototype = {
96 96 this.vx = 0;
97 97 this.left = intercept.x - this.width;
98 98 this.top = intercept.y;
  99 + playSfx("bonk-sfx")
99 100 break;
100 101 case "right":
101 102 this.vx = 0;
102 103 this.left = intercept.x;
103 104 this.top = intercept.y;
  105 + playSfx("bonk-sfx")
104 106 break;
105 107 case "bottom":
106 108 this.vy = 0;
107 109 this.left = intercept.x;
108 110 this.top = intercept.y;
  111 + playSfx("bonk-sfx")
109 112 break;
110 113 }
111 114 },
@@ -130,6 +133,7 @@ Mob.prototype = {
130 133 // my head.
131 134 if (this.onGround() && !this.jumping &&
132 135 ! TheWorld.touchingPlatform(this, "top")) {
  136 + playSfx("jump-sfx");
133 137 this.vy -= this.jumpPower;
134 138 this.jumping = true; // to make jump idempotent, fix bug 2
135 139 }
@@ -240,6 +244,7 @@ Enemy.prototype = {
240 244 this.die();
241 245 // TODO death animation?
242 246 mob.vy = -10; // bounce
  247 + playSfx("crunch-sfx");
243 248 } else {
244 249 mob.die();
245 250 }
5 webrunner-play.js
@@ -93,6 +93,7 @@ $(document).ready(function() {
93 93 if (player.intersecting(TheWorld.goalArea)) {
94 94 $("#output").html("A WINRAR IS YOU!");
95 95 $("#bgm")[0].pause();
  96 + playSfx("victory-sfx");
96 97 // TODO play victory sound effects!
97 98 window.clearInterval(heartbeat);
98 99 $.ajax({type: "POST",
@@ -114,13 +115,13 @@ $(document).ready(function() {
114 115 $("#output").html("YOU'RE MONSTER CHOW (reload to play again)");
115 116 window.clearInterval(heartbeat);
116 117 $("#bgm")[0].pause();
117   - // TODO play death sound effects!
  118 + playSfx("death-sfx");
118 119 }
119 120 if (player.top > bottomLimit) {
120 121 $("#output").html("GRAVITY IS A HARSH MISTRESS (reload to play again)");
121 122 window.clearInterval(heartbeat);
122 123 $("#bgm")[0].pause();
123   - // TODO play death sound effects
  124 + playSfx("death-sfx");
124 125 }
125 126 }, 100);
126 127 });
1  webrunner-world.js
@@ -657,6 +657,7 @@ PointlessTrinket.prototype = {
657 657 }
658 658 },
659 659 onCollect: function(player) {
  660 + playSfx("kaching-sfx");
660 661 if (player.numTrinkets == 0) {
661 662 player.numTrinkets = 1;
662 663 } else {

0 comments on commit 0bc363b

Please sign in to comment.
Something went wrong with that request. Please try again.