Game loop library for Node.js.
$ npm install --save https://github.com/mtojo/node-game.git
const Game = require('game');
const game = new Game({
framesPerSecond: 60,
maxFrameSkip: 10,
waitTime: 0
});
game.on('init', () => {
// This function is called when the Game object is initialized.
});
game.on('start', () => {
// This function is called when the game loop is started.
});
game.on('update', () => {
// This function is called every frame.
});
game.on('stop', () => {
// This function is called when the game loop is stopped.
});
game.start();
Name | Description | Default |
---|---|---|
framesPerSecond |
Frames per second. | 60 |
maxFrameSkip |
Max number for frame skip. | 10 |
waitTime |
Milliseconds for loop wait. | 0 |
type: boolean
Returns whether the game loop is running.
type: number
Returns the number of the updated.
type: number
Returns the number of the updated on current second.
type: number
Sets the frames per second.
type: number
Returns the frames per second.
type: number
Sets the max number for frame skip.
type: number
Returns the max number for frame skip.
type: number
Sets the milliseconds for loop wait.
type: number
Returns the milliseconds for loop wait.
Starts the game loop.
Stops the game loop.
MIT