smolworld / src /js /time.js
p3nGu1nZz's picture
✨ Add core game engine components including Scene, Layer, Time management, and input handling; implement configuration management
7b453e7
raw
history blame contribute delete
449 Bytes
export class Time {
static deltaTime = 0;
static lastTime = performance.now();
static fixedDeltaTime = 1 / 60;
static accumulatedTime = 0;
static update() {
const now = performance.now();
Time.deltaTime = (now - Time.lastTime) / 1000;
Time.lastTime = now;
Time.accumulatedTime += Time.deltaTime;
}
static resetAccumulator() {
Time.accumulatedTime -= Time.fixedDeltaTime;
}
}