Commits

Anonymous committed ee07f04

sounds, hooray

Comments (0)

Files changed (8)

public/gamepkg/assets/audio/fire.wav

Binary file added.

public/gamepkg/assets/audio/otherPlayerDestroyed.wav

Binary file added.

public/gamepkg/assets/audio/playerDestroyed.wav

Binary file added.

public/gamepkg/assets/img/butterfly2_large.jpg

Removed
Old image

public/gamepkg/assets/img/sample.jpg

Added
New image

public/gamepkg/game.js

+var fire, shipExp, selfExp;
 $(document).ready(function(){
+    if('Audio' in window){
+        fire = new Audio('/gamepkg/assets/audio/fire.wav');
+        fire.volume = 0.5;
+        
+        selfExp = new Audio('/gamepkg/assets/audio/playerDestroyed.wav');
+        selfExp.volume = 0.35;
+        
+        shipExp = new Audio('/gamepkg/assets/audio/otherPlayerDestroyed.wav');
+        shipExp.volume = 0.35;
+    }
     Crafty.init(640, 480);
     var preloadAssets = [
-        '/gamepkg/assets/img/butterfly2_large.jpg'
+        '/gamepkg/assets/img/sample.jpg'
     ];
     var preloadScripts = [
         'ui',

public/gamepkg/scripts/playerCharacter.js

             // if is player
             if(this.has('Player')){
                 // gameOver
+                if(selfExp){
+                    selfExp.play();
+                }
+                
                 Crafty.scene('GameOver');
             }
+            else if(shipExp){
+                shipExp.play();
+            }
         })
         
         this.bind('EnterFrame', function(){
             }
             this.nametag.text(this.name);
             if(this.firing){
+                if(fire && fire.paused){fire.paused = false; fire.play();}
                 for(var i=0; i < this.weapons.length; i++){
                     var wep = this.weapons[i];
                     Crafty(wep).fire();
                 }
             }
+            else{
+                if(fire){fire.pause();}
+            }
         });
         
     },

public/gamepkg/scripts/sceneGameOver.js

 Crafty.scene('GameOver', function(){
+    comm.close();
     Crafty.e("ui-title")
     .attr({
         w: 640,