I\'m writing an HTML5 Game Development Javascript framework and I want to provide the user the difference in time between the last tick and the current one.
Are you over thinking it?
var myInterval = window.setInterval(calculateForDeltaHere , 20); function calculateForDeltaHere () { /* Calculate delta time */ dt = Math.random(); tick(dt); } function tick() { update(); draw(); }
And when you want to stop the interval
window.clearInterval(myInterval);