gameloop

super simple game loop for javascript – server or browser.

gameloop

the core methods/events of a game loop: start, end, pause, resume, update, draw

Designed for use with browserify.

  • node.js
npm install gameloop
var canvas = document.createElement('canvas');
 
var game = new Game({
  renderer: canvas.getContext('2d')
});

You can use it server-side by not passing in a canvas context: var game = Game();

the new keyword is optional

game.on('update', function(dt){});
 
game.on('draw', function(context){});
game.start();
 
game.end();
 
game.pause();
 
game.resume();

These methods have corresponding events:

game.on('start', function(){});
 
game.on('end', function(){});
 
game.on('pause', function(){});
 
game.on('resume', function(){});
  • Fork this repository.
  • Create a branch for your changes.
  • Include tests if applicable.
  • Add/edit documentation for any changes.
  • Submit a pull request.

MIT