Skip to content

Commit

Permalink
Add slightly random max jump speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Golen87 committed Nov 19, 2023
1 parent 66b1a05 commit cd2967c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/Turtle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand Down

0 comments on commit cd2967c

Please sign in to comment.