adding 502 error
This commit is contained in:
28
games/space-invaders404/js/game.js
Normal file
28
games/space-invaders404/js/game.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// Reset the game when the player catches a monster
|
||||
var reset = function () {
|
||||
hero.x = canvas.width / 2;
|
||||
hero.y = canvas.height - 64;
|
||||
};
|
||||
|
||||
// The main game loop
|
||||
var main = function () {
|
||||
var now = Date.now();
|
||||
var delta = now - then;
|
||||
|
||||
update(delta / 1000);
|
||||
render();
|
||||
|
||||
then = now;
|
||||
|
||||
// Request to do this again ASAP
|
||||
requestAnimationFrame(main);
|
||||
};
|
||||
|
||||
// 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();
|
||||
reset();
|
||||
main();
|
||||
Reference in New Issue
Block a user