From c9d06a224827e426cd9c36ff212053d138b3c364 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Thu, 12 Jan 2023 11:05:36 +0100 Subject: [PATCH] qol changes to the numbers of game --- frontend/game.ts | 24 ++++++++++++++++++++++-- frontend/model/Raspberry.ts | 4 ++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/frontend/game.ts b/frontend/game.ts index f99cb76..03875b7 100644 --- a/frontend/game.ts +++ b/frontend/game.ts @@ -206,8 +206,7 @@ function keyPressed() { if (!ready) return; // Jump if (BOOST_KEYS.includes(key.toLowerCase())) { - resetScore(); - raspberry.boost(); + playerInput(); } // Pause the Game @@ -217,3 +216,24 @@ function keyPressed() { paused = false; } } + +/** + * Mouse clicked event. + */ +function mouseClicked() { + if (!ready) return; + + if (paused) { + paused = false; + } + + playerInput(); +} + +/** + * Handles input for the player, when a key is pressed, or the mouse is clicked. + */ +function playerInput() { + resetScore(); + raspberry.boost(); +} diff --git a/frontend/model/Raspberry.ts b/frontend/model/Raspberry.ts index 779d596..62aa0a1 100644 --- a/frontend/model/Raspberry.ts +++ b/frontend/model/Raspberry.ts @@ -36,7 +36,7 @@ class Raspberry extends Entity { * Maximum velocity, so the raspberry doesn't get to infinite speed when boosting. * @private */ - private static readonly maxVelocity: number = 100; + private static readonly maxVelocity: number = 75; /** * Width. @@ -70,7 +70,7 @@ class Raspberry extends Entity { * @param value */ set velocity(value: number) { - this._velocity = (Math.abs(this.velocity) > Raspberry.maxVelocity) ? Raspberry.maxVelocity : value; + this._velocity = (Math.abs(this.velocity) > Raspberry.maxVelocity) ? -Raspberry.maxVelocity : value; } /**