FIXED AND WORKING... BACKUP IF IT GOES WRONG
This commit is contained in:
27
src/app/home/deltaTime.ts
Normal file
27
src/app/home/deltaTime.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export class DeltaTime {
|
||||
private lastTick: number;
|
||||
private static instance: DeltaTime;
|
||||
private deltaTime: number;
|
||||
|
||||
private constructor() {
|
||||
this.lastTick = Date.now();
|
||||
}
|
||||
|
||||
public static getInstance() {
|
||||
if (!this.instance) {
|
||||
this.instance = new DeltaTime();
|
||||
}
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
public updateDeltaTime() {
|
||||
const time = Date.now();
|
||||
this.deltaTime = time - this.lastTick;
|
||||
this.lastTick = time;
|
||||
}
|
||||
|
||||
public getDeltaTime(): number {
|
||||
return this.deltaTime;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user