mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-25 11:18:54 +00:00
22 lines
490 B
TypeScript
22 lines
490 B
TypeScript
export class GameTimer {
|
|
private targetDelay: number;
|
|
private currentDelay = 0;
|
|
|
|
public constructor(targetDelay: number) {
|
|
this.targetDelay = targetDelay;
|
|
}
|
|
|
|
public gameTick(deltaTime: number): void {
|
|
this.currentDelay += deltaTime;
|
|
}
|
|
|
|
public tryFinishPeriod(): boolean {
|
|
if (this.targetDelay <= this.currentDelay) {
|
|
this.currentDelay = 0;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|