From a30260bcf436623a39e2c9b96aa0ab45be0f2186 Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 27 Feb 2024 08:22:32 +0100 Subject: [PATCH] game: fix: w is to up and s to down --- frontend/static/js/api/game/MyPlayer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/static/js/api/game/MyPlayer.js b/frontend/static/js/api/game/MyPlayer.js index f370d51..5cd1ddd 100644 --- a/frontend/static/js/api/game/MyPlayer.js +++ b/frontend/static/js/api/game/MyPlayer.js @@ -19,6 +19,8 @@ class MyPlayer extends Player * @type {Client} */ this.client = client; + + this.increment_sign = this.rail.start.y > this.rail.stop.y ? 1 : -1; } /** @@ -29,9 +31,9 @@ class MyPlayer extends Player let new_pos = this.position; if (keys_pressed.includes("s")) - new_pos -= this.game.config.paddle_speed_per_second_max * this.game.time.deltaTimeSecond() * 1.0; + new_pos -= this.game.config.paddle_speed_per_second_max * this.game.time.deltaTimeSecond() * 1.0 * this.increment_sign; if (keys_pressed.includes("w")) - new_pos += this.game.config.paddle_speed_per_second_max * this.game.time.deltaTimeSecond() * 1.0; + new_pos += this.game.config.paddle_speed_per_second_max * this.game.time.deltaTimeSecond() * 1.0 * this.increment_sign; 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);