Problems with JQuery (Box2D) - Sound on collision

Problems with JQuery (Box2D) - Sound on collision

Good afternoon fellow JQuery users. 

My group at University and I are trying to create an interactive site using box2d and sound on collision. So far we have this:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Remediation</title>
  5.     <link rel="stylesheet" type="text/css" href="../2014-05-21-jquery-box2d/css/main.css">
  6.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  7. </head>

  8. <body>

  9. <img src="img/img1.png" alt="Background Image One" width=100% height=100%>
  10.    
  11.     <div class="box">
  12.     <p class="boxtext">Just get me the keys, Henry</p>
  13.    </div>   
  14.    
  15.     <div class="box">
  16.     <p class="boxtext">Why? Why is he coming over?</p>
  17.    </div>   
  18.    
  19.     <div class="box">
  20.     <p class="boxtext">Please, just go and get them.</p>
  21.    </div>   
  22.    
  23.     <div class="box">
  24.     <p class="boxtext">What&#39;s going on?</p>
  25.    </div>   
  26.    
  27.     <div class="box">
  28.     <p class="boxtext">This is good, you know. I think you&#39;re getting better</p>
  29.    </div>   
  30.    
  31.     <div class="box">
  32.     <p class="boxtext">You&#39;re either sick or you&#39;re in trouble. And you don&#39;t look sick</p>
  33.    </div>   
  34.    
  35.     <div class="box">
  36.     <p class="boxtext">I think I saw one of your paintings by the station. Did you do one there? On the wall behind the car park? </p>
  37.    </div>   
  38.    
  39.     <div class="box">
  40.     <p class="boxtext">You&#39;re in trouble aren&#39;t you? You did something</p>
  41.    </div>   
  42.    
  43.     <div class="box">
  44.     <p class="boxtext">And you don&#39;t look sick</p>
  45.    </div>   
  46.    
  47.     <div class="box">
  48.     <p class="boxtext">It was really pretty</p>
  49.    </div>   
  50.    
  51.     <div class="box">
  52.     <p class="boxtext">Mia?!</p>
  53.    </div>   
  54.    
  55.     <div class="box">
  56.     <p class="boxtext">I wish you&#39;d draw me</p>
  57.    </div>   
  58.    
  59.     <div class="box">
  60.     <p class="boxtext">Why did they call?</p>
  61.    </div>   
  62.    
  63.     <div class="box">
  64.     <p class="boxtext">Just get me the keys Henry</p>
  65.    </div>   
  66.    
  67.     <div class="box">
  68.     <p class="boxtext">Not until you tell me</p>
  69.    </div>   
  70.    
  71.     <div class="box">
  72.     <p class="boxtext">Fine I&#39;ll find them</p>
  73.    </div>   
  74.    
  75.     <div class="box">
  76.     <p class="boxtext">Mia spit it out</p>
  77.    </div>   
  78.    
  79.     <div class="box">
  80.     <p class="boxtext">You don&#39;t, you won&#39;t. You don&#39;t want to know you&#39;ll hate me</p>
  81.    </div>   
  82.    
  83.     <div class="box">
  84.     <p class="boxtext">I could never hate you.</p>
  85.    </div>   
  86.    
  87.     <div class="box">
  88.     <p class="boxtext">What are they going to do to me?</p>
  89.    </div>   
  90.    
  91.     <div class="box">
  92.     <p class="boxtext">Who?</p>
  93.    </div>   
  94.    
  95.     <div class="box">
  96.     <p class="boxtext">The school, you fool. They&#39;re going to expel me, Hen. I just know they are, and Dad. Oh god</p>
  97.    </div>   
  98.    
  99.     <div class="box">
  100.     <p class="boxtext">Mia I don&#39;t care. I won&#39;t hate you. I promise I won&#39;t. I promise. Just tell me</p>
  101.    </div>   
  102.    
  103.     <div class="box">
  104.     <p class="boxtext">Fuck Fuck Fuck.</p>
  105.    </div>
  106.    
  107.    

  108. <script type="text/javascript" src="../2014-05-21-jquery-box2d/box2d/js/lib/jquery.box2d.js"> </script>
  109. <script type="text/javascript">

  110. $(document).ready(function(){

  111.     console.log("loaded");
  112.     $('.box').each(function(index, elm){
  113.         var xPos = Math.floor((Math.random() * 1000) + 1);
  114.         var yPos = Math.floor((Math.random() * 700) + 1);
  115.  
  116.         $(this).css("left", xPos + "px").css("top", yPos + "px");

  117.     });

  118.     $('.box').on('click', function(){

  119.          $(this).box2d({'y-velocity':10, 'density': 5, 'restitution': 0.4, 'friction': 0.3, 'shape': 'box'});        
  120.             
  121.     });
  122. --> I couldn't get this working:
  123. --> $('.box').click(function(){
  124. --> $('#wrap').append('<embed id="embed_player" src="snd/track.wav" autostart="true" hidden="true"></embed>');

  125. });




  126. </script>


  127. </body>
  128. </html>

Our CSS is as follows:

  1. @charset "UTF-8";
  2. /* CSS Document */

  3.  html,
  4.  body {
  5.    width: 100%;
  6.  height: 100%;
  7. }

  8.  #bg {
  9. width: 100%;
  10. height: 100%;
  11. background-color: #000000;
  12. position: absolute;
  13. margin: auto;
  14. }

  15.      .box{
  16.             position:absolute;
  17.             background-color:#99F;
  18.             width: flexible;
  19.             height: flexible;
  20. padding: 15px;
  21.         }
  22.  .boxtext{
  23.   font-family:helvetica;
  24. color:#000;
  25. font-size:14px;
  26. text-align:center;
  27.  
  28.  }
We need help with individual sounds playing per box. Although we are aware that the code uses only one class, is it possible to play unique sounds per box? Or can anyone point us in the right direction on how to include sound when the boxes collide (even if the same sound, as a start).

Cheers