https://github.com/fabiosantoscode/game-ticker
Implements a game loop where you can register update and render functions, to be supplied with time delatas and other information.
https://github.com/fabiosantoscode/game-ticker
Last synced: 6 months ago
JSON representation
Implements a game loop where you can register update and render functions, to be supplied with time delatas and other information.
- Host: GitHub
- URL: https://github.com/fabiosantoscode/game-ticker
- Owner: fabiosantoscode
- License: mit
- Created: 2018-09-23T17:41:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-24T17:30:47.000Z (over 7 years ago)
- Last Synced: 2025-07-02T22:41:49.553Z (7 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# game-ticker
Implements a game loop where you can register update and render functions, to be supplied with time delatas and other information.
## const end = require('game-ticker')({ update: () => {...}, render: () => {...}, updatesPerSecond, maxFPS})
Starts the game ticker. Returns a function to end it.
Takes the following options:
- `update`: The function to call every (1000 / updatesPerSecond) milliseconds
- `render`: The function to call after requestAnimationFrame
- `updatesPerSecond`: The number of desired updates per second
- `maxFPS`: The maximum allowed FPS
Example:
```javascript
const gameTicker = require('game-ticker')
const end = gameTicker({
update(timeInfo, dt) {
// do stuff with dt
},
render(timeInfo, intoNextUpdate) {
// do stuff with current state and intoNextUpdate for interpolation
},
updatesPerSecond: 12,
maxFPS: 30
})
```