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);