mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-25 19:28:53 +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;
|
||
|
}
|
||
|
}
|
||
|
}
|