topical media & game development

talk show tell print

mobile-game-ch09-gameloop-test.htm / htm



  <!DOCTYPE HTML>
  <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title></title>
  
      <script src='mobile-game-ch09-jquery.min.js'></script>
      <script src='mobile-game-ch09-underscore.js'></script>
      <script src='mobile-game-ch09-quintus.js'></script>
    </head>
    <body>
      <div id='timer'>0</div>
      <div id='fps'>0</div>
      <button id='pause'>Pause</button>
      <button id='unpause'>Unpause</button>
  
      <script>
        var TimerTest = Quintus();
        
        var totalFrames = 0, totalTime = 0;;
        TimerTest.gameLoop(function(dt) {
            totalTime += dt;
            totalFrames += 1;
            $("#timer").text(Math.round(totalTime * 1000) + " MS");
            $("#fps").text(Math.round(totalFrames / totalTime) + " FPS");
        });
  
        $("#pause").on('click',TimerTest.pauseGame);
        $("#unpause").on('click',TimerTest.unpauseGame);
  
      </script>
  
    </body>
  </html>
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.