Skip to content

Instantly share code, notes, and snippets.

@Zerrien
Created April 29, 2016 01:00
Show Gist options
  • Save Zerrien/2dbb51bc8349a03ffcd36a7ce7a7b488 to your computer and use it in GitHub Desktop.
Save Zerrien/2dbb51bc8349a03ffcd36a7ce7a7b488 to your computer and use it in GitHub Desktop.
<html>
<head>
<script>
var canvas, ctx;
var sTime, dTime, pTime, tTime;
function init() {
canvas = document.getElementById("aCanvas");
ctx = canvas.getContext('2d');
pTime = (new Date()).getTime();
tTime = 0;
setInterval(main, 10);
}
function main() {
sTime = (new Date()).getTime();
dTime = sTime - pTime;
tTime += dTime;
// Add logic here.
pTime = sTime;
}
</script>
</head>
<body onload="init()">
<canvas id="aCanvas"></canvas>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment