title: Make the character jump Based on Fps and Time
body: <p>i am trying to make a character based on Time and FPS.</p>
  
  <p>What i need is make my character jump last for exactly 1 second.Right now i am using below code and it makes the character jump for 1 second.But problem is ..if the fps is 60 character moves 60 pixels , and if fps is 30 it moves only 30 pixels...How can i solve this..</p>
  
  <p>I need character to move 60 pixels regardless fps and within 1 second.</p>
  
  <pre><code>//Below is the requestanimation frame loop
  // which runs the loop 60 to 30 times per second , 
  //  which vary according to browser.
  
      function jumpcheck()
      {
      if(isjump)
      {
      ball.posy -=1; //make the character move 10 px based on fps..
  
  
      window.timeoutHandle = window.setTimeout(function() {
      isjump = false;
      }, 1000);
      }
  
  
  
  
  
      }
      }
  </code></pre>
  
  <p>note:request animation frame fps is something between 20 to 60 always changing.</p>
  
  <p>Code as said by constantinous</p>
  
  <pre><code>var lastUpdate = Date.now();
  function jumpcheck()
  {
  if(isjump)
  {
  speed = 1;
  position = ball.posy;
  var now = Date.now();
  var dt = (now - lastUpdate) / 1000;
  lastUpdate = now;
  ball.posy = position + (speed * dt)
  
  }
  }
  </code></pre>