From 0c759245c7f46e49aec281f7e52b6403567861bb Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 2 Dec 2022 23:11:25 +0100 Subject: [PATCH] fix rotation --- js/Player.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/Player.js b/js/Player.js index e934734..2f445da 100644 --- a/js/Player.js +++ b/js/Player.js @@ -22,7 +22,7 @@ export class Player extends Cube { if (demo) { listEnnemies.forEach((ennemy) => { const pos = ennemy.position.x - this.data.position.x; - if (pos < Math.random() * 2.8 + 0.2 && pos > 0) { + if (pos < Math.random() * 1.5 + 0.5 && pos > 0) { dispatchEvent(jumpDemo); } }); @@ -31,7 +31,7 @@ export class Player extends Cube { // If we jump if (this.movementData.state) { // Rotation - this.data.rotation.y -= this.movementData.rotationVelocity; + this.data.rotation.y -= this.movementData.rotationVelocity / 1.6; // If we're falling (2nd part of the jump) if (this.movementData.falling()) { @@ -69,8 +69,12 @@ export class Player extends Cube { */ controlUser = (key) => { if (key.code == "Space" && !this.movementData.state) { - this.movementData.changeRotation(this.data.rotation.y - Math.PI); - this.movementData.changeJump(this.data.position.y + Math.PI); + this.movementData.changeRotation( + this.data.rotation.y - Math.PI / 2 + ); + this.movementData.changeJump( + 3 * this.data.position.y + Math.PI / 2 + ); this.movementData.changeState(); } };