Files
Docker-404-games/404_games/snake/js/framework.js
2024-01-13 18:20:27 +01:00

35 lines
625 B
JavaScript

// The main game loop
var main = function () {
var now = Date.now();
var delta = now - then;
controls();
render();
then = now;
// Request to do this again ASAP
requestAnimationFrame(main);
};
//var canvas = document.createElement('canvas');
//document.body.appendChild(canvas);
setInterval(function(){update()}, 300);
// Cross-browser support for requestAnimationFrame
var w = window;
requestAnimationFrame =
(
w.requestAnimationFrame ||
w.webkitRequestAnimationFrame ||
w.msRequestAnimationFrame ||
w.mozRequestAnimationFrame
);
// Let's play this game!
var then = Date.now();
initGameState(main);