Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashkyd/superloop
A game loop library to handle both render and game state.
https://github.com/ashkyd/superloop
Last synced: 4 days ago
JSON representation
A game loop library to handle both render and game state.
- Host: GitHub
- URL: https://github.com/ashkyd/superloop
- Owner: AshKyd
- License: mit
- Created: 2013-12-27T13:07:51.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-16T14:08:33.000Z (over 10 years ago)
- Last Synced: 2024-11-10T14:48:52.465Z (2 months ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
superloop
=========A game loop library to handle both render and game state.
Traditionally code examples recommend requestAnimationFrame to handle the game
loop, but this falls down because the optimisations to rAF mean it cna stop
firing when a window is minimised or the user is viewing another tab.For games that need to continue playing, this is unacceptable and can lead to
heartache down the track.This library uses both requestAnimationFrame with an optimised fallback to the
traditional setTimeout so the game loop continues to fire even when the page
isn't focused.Usage
-----
This has barely been tested and isn't production ready yet, so don't use it
unless you're prepared to deal with API changes and fix issues as they arise.To create a SuperLoop, use the following:
var myLoop = new SuperLoop({
ontick: function(){
// Your tick stuff goes here.
// (Unit movement, collision detection, housekeeping)
},
onrender: function(){
// Your render stuff goes here.
// (Drawing to screen)
}
});Tests
-----
SuperLoop uses Mocha for testing. At the moment there's only the one test, but
I'm getting to it.