title: Javascript image collision
body: <p>Okay so I have 2 images, player and enemy. I have created a function to check for collision between both the images. I have tried to get them to collide like you would see on a 2d platformer but instead of stopping the player for going over the image; as soon as they collide the player image freeze in the same x&amp;y co ord. Here is there code I have.</p>
  
  <p>//FUNCTION</p>
  
  <pre><code>function CollisionCheck(Img1, Img2, Obj1, Obj2, width){
      if(Obj1.x &lt; Obj2.x + width &amp;&amp; Obj1.x + width &gt; Obj2.x &amp;&amp; Obj1.y &lt; Obj2.y + width &amp;&amp; Obj1.y + width &gt; Obj2.y){
          colliding = true;
          return;
      }else{
          colliding = false;
          return;   
      }
  };
  </code></pre>
  
  <p>//WHILE LOOP TO CHECK FOR COLLISION (THIS COULD BE THE PROBLEM)</p>
  
  <pre><code>CollisionCheck(playerImg, enemyImg, player, enemy, 32);
      while(colliding){
          var x = player.x;
          var y = player.y;
          player.x = x;
          player.y = y;
          if(colliding = false){
              return;   
          }
      }
  </code></pre>