Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

gameloopjs

0.1.0 • Public • Published

gameloop v0.1.0

Simple game loop

Usage

Basic Usage

var func = function () { console.log('step'); };
 
var loop = gameloop(func);
 
loop.start();
 
setTimeout(function () {
 
    loop.stop();
 
}, 5000);

In the above example func is called 30 times per second and is stopped after 5 seconds.

Set fps

var loop = gameloop(func);
 
loop.setFPS(60);
 
loop.start(); // func is called 60 times per second

In the above example func is called 60 time per second.

API

start

Starts the game loop.

stop

Stops the game loop.

setFPS

Sets the fps of the loop. (Default fps is 30.)

Install

Node.js

npm install --save gameloopjs
var gameloop = require('gameloopjs');
 
 
var loop = gameloop(function () { console.log('step'); });
 
loop.start();

Browser

bower install --save gameloop
<script src="path/to/gameloop.js"></script>
 
<script>
 
var loop = gameloop(function () {
 
    console.log('step');
 
});
 
</script> 

License

MIT

install

npm i gameloopjs

Downloadsweekly downloads

0

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability