From cd2967c304a39f3398d7aa5e216c7519bb9252cd Mon Sep 17 00:00:00 2001 From: Golen Date: Sun, 19 Nov 2023 17:06:48 +0100 Subject: [PATCH] Add slightly random max jump speed --- src/components/Turtle.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Turtle.ts b/src/components/Turtle.ts index b64a009..733c1a3 100644 --- a/src/components/Turtle.ts +++ b/src/components/Turtle.ts @@ -42,6 +42,7 @@ export class Turtle extends Button { private hasCrashed: boolean; private jumpTarget: Phaser.Geom.Point; private jumpTargetTween: Phaser.Tweens.Tween; + private maxJumpSpeed: number; public bounceCount: number; constructor( @@ -91,6 +92,7 @@ export class Turtle extends Button { this.hasCrashed = false; this.jumpTarget = new Phaser.Geom.Point(); this.newJumpTarget(); + this.maxJumpSpeed = Phaser.Math.RND.between(27, 31); this.bounceCount = 0; /* Input */ @@ -113,7 +115,7 @@ export class Turtle extends Button { this.physicsPosition.y + this.feetOffset >= this.trampoline.zone.bottom ) { - let maxSpeed = 30; + let maxSpeed = this.maxJumpSpeed; let landSpeed = Math.max(this.physicsVelocity.y, 2); let jumpSpeed = Phaser.Math.Easing.Sine.Out(landSpeed / maxSpeed) * maxSpeed;