core: split: game and pong

This commit is contained in:
2024-04-05 17:47:17 +02:00
parent c49e721e5a
commit f6f59f8ead
34 changed files with 965 additions and 784 deletions

View File

@ -0,0 +1,42 @@
class Time
{
constructor()
{
/**
* @type {Number}
*/
this._lastFrame = undefined;
/**
* @type {Number}
*/
this._currentFrame = undefined;
}
deltaTime()
{
if (this._lastFrame === undefined)
return 0;
return (this._currentFrame - this._lastFrame);
}
deltaTimeSecond()
{
return this.deltaTime() / 1000;
}
get_fps()
{
return 1 / this.deltaTimeSecond();
}
new_frame()
{
this._lastFrame = this._currentFrame;
this._currentFrame = Date.now();
}
}
export { Time };