title: HTML5 and Canvas: Moving background with player's movement
body: <p>I am trying to make an HTML5 game using Canvas. I have a piece of code which supposed to move bg:</p>
  
  <pre><code>function drawScene() { // main drawScene function
  clear(); // clear canvas
  // draw background
  context = document.getElementById("gameCanvas").getContext('2d');
  bgShiftX -= 3;
  if (bgShiftX &lt;= -100) {
     bgShiftX = 0;
  }
    context.drawImage(floor, 0 + bgShiftX, 410);
    context.drawImage(city, 0 + bgShiftX, 175);
  }
  </code></pre>
  
  <p>But I can't figure out how to make it move smooth and do not jump when it reaches -100px on X, so I need it move continuously. And also I want it to move when player press moveKey and reaches middle of the screen.</p>