game: add: PADDLE CAN MOVE
This commit is contained in:
33
frontend/static/js/api/game/Time.js
Normal file
33
frontend/static/js/api/game/Time.js
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
class Time
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this._last_frame = undefined;
|
||||
this._current_frame = undefined;
|
||||
}
|
||||
|
||||
deltaTime()
|
||||
{
|
||||
return (this._current_frame - this._last_frame) !== NaN ? this._current_frame - this._last_frame : 0;
|
||||
}
|
||||
|
||||
deltaTimeSecond()
|
||||
{
|
||||
return this.deltaTime() / 1000;
|
||||
}
|
||||
|
||||
get_fps()
|
||||
{
|
||||
return 1 / this.deltaTimeSecond();
|
||||
}
|
||||
|
||||
new_frame()
|
||||
{
|
||||
this._last_frame = this._current_frame;
|
||||
this._current_frame = Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
export { Time }
|
Reference in New Issue
Block a user