From 7096989e9b9ca6180dc1998a81fadc015ff8df61 Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 16 Jan 2024 17:51:47 +0100 Subject: [PATCH] game: opti: use time class --- frontend/static/js/api/game/MyPlayer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/static/js/api/game/MyPlayer.js b/frontend/static/js/api/game/MyPlayer.js index f33d03d..caff0a8 100644 --- a/frontend/static/js/api/game/MyPlayer.js +++ b/frontend/static/js/api/game/MyPlayer.js @@ -15,9 +15,9 @@ class MyPlayer extends Player let new_pos = this.pos; if (keys_pressed.includes("s")) - new_pos -= this.game.config.paddle_speed_per_second_max * this.time.deltaTimeSecond() * 1; + new_pos -= this.game.config.paddle_speed_per_second_max * this.time.deltaTimeSecond() * 1.0; if (keys_pressed.includes("w")) - new_pos += this.game.config.paddle_speed_per_second_max * this.time.deltaTimeSecond() * 1; + new_pos += this.game.config.paddle_speed_per_second_max * this.time.deltaTimeSecond() * 1.0; new_pos = Math.max(0 + this.game.config.paddle_ratio / 2, new_pos); new_pos = Math.min(1 - this.game.config.paddle_ratio / 2, new_pos); @@ -33,7 +33,7 @@ class MyPlayer extends Player { let position_verified = new_position; - let time_diff = (Date.now() - time) / 1000; + let time_diff = (this.time._current_frame - time) / 1000; let sign = this - new_position >= 0 ? 1 : -1;