title: HTML5 canvas and javascript move player with mouse movement
body: <p>okay so far i can move the player with the arrow keys but i have been trying to figure out how to move the player with mouse movements such as moving the mouse to the right will increase the players X position and moving the mouse to the left will decrease the X position but i'm struggling to achieve this!</p>
  
  <p>how i made my player object</p>
  
  <pre><code>player = {
      x: width / 30,//player properties 
      y: height - 5,
      width: 16,
      height: 18,
      speed: 3,
      velX: 0,
      velY: 0,
      jumping: false,
      grounded: false
  
  },
  </code></pre>
  
  <p>my control functions</p>
  
  <pre><code> if (keys[38] || keys[32]) {
      // up arrow or space
      if (!player.jumping &amp;&amp; player.grounded) {
          player.jumping = true;
          player.grounded = false;
          player.velY = -player.speed * 2;
          var audio = new Audio('jump.mp3');
          audio.play();
      }
  }
  if (keys[39]) {
  //mouseControl = false;
      // right arrow
      if (player.velX &lt; player.speed) {
          player.velX++;
  
  if(count ==2)
   {
   count = 0;
   }
  else {
   count++;
  }
      }
  }
       if (keys[37]) {
     //mouseControl = false;
      // left arrow
      if (player.velX &gt; -player.speed) {
          player.velX--;
          if(count ==2)
    {
     count = 0;
  
  }
   else {
   count++;
   }
      }
  }
  
  player.velX *= friction;
  player.velY += gravity;
  
  ctx.clearRect(0, 0, width, height);
  ctx.fillStyle = "black";
  ctx.beginPath();
  
  player.grounded = false;
  }
  </code></pre>
  
  <p>how i'm getting the keys</p>
  
  <pre><code> //if key is pressed down = true
   document.body.addEventListener("keydown", function (e) {
      keys[e.keyCode] = true;
   });
   //if key is not pressed = false
   document.body.addEventListener("keyup", function (e) {
  keys[e.keyCode] = false;
   });
  
  
   window.addEventListener("load", function () {
  game_loop();
   });
  </code></pre>