af3ec008c9
previously it was passed in milliseconds.
15 lines
306 B
JavaScript
15 lines
306 B
JavaScript
const tickers = [];
|
|
|
|
export function register_tick (callback) {
|
|
tickers.push(callback);
|
|
}
|
|
|
|
let last_tick = new Date().getTime();
|
|
export function tick () {
|
|
const deltatime = new Date().getTime() - last_tick;
|
|
last_tick += deltatime;
|
|
|
|
for (const callback of tickers) {
|
|
callback(deltatime / 1000);
|
|
}
|
|
}
|