Initial commit
This commit is contained in:
34
404_games/snake/js/framework.js
Normal file
34
404_games/snake/js/framework.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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);
|
||||
Reference in New Issue
Block a user