Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Chocobois/TurtleTrampoline
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcticFqx committed Nov 19, 2023
2 parents 4e808f6 + 9db7af2 commit df5448a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/Turtle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class Turtle extends Button {
this.spriteSize = 200;
this.sprite = this.scene.add.sprite(0, 0, "turtle_waiting");
this.sprite.setScale(this.spriteSize / this.sprite.width);
this.add(this.sprite);
// this.add(this.sprite);

/* Controls */
this.physicsPosition = new Phaser.Math.Vector2(x, y);
Expand Down Expand Up @@ -250,6 +250,17 @@ export class Turtle extends Button {
this.sprite.setTexture("turtle_jumping");
}
}

// Depth sorting
this.sprite.setPosition(this.x, this.y);
let depth = 100;
if (this.isOnTrampoline) {
depth += this.jumpTarget.y / 100;
} else {
depth += this.walkTarget.y / 100;
}
if (this.hold) depth += 100;
this.sprite.setDepth(depth);
}

/* Jumping */
Expand Down Expand Up @@ -354,7 +365,7 @@ export class Turtle extends Button {
this.lostBalance = false;
this.hasCrashed = false;
this.bounceCount = 0;
this.onDrag(pointer, 0, 0);
this.onDrag(pointer, this.x, this.y);
}

onDrag(pointer: Phaser.Input.Pointer, dragX: number, dragY: number) {
Expand Down
8 changes: 8 additions & 0 deletions src/scenes/OverworldState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ export class OverworldState extends Phaser.GameObjects.Container {
});
}

setVisible(value: boolean): this {
this.turtles.forEach((turtle) => {
turtle.sprite.setVisible(value);
});

return super.setVisible(value);
}

addDust(x: number, y: number)
{
let xpl = this.scene.add.sprite(x, y, 'dust_explosion');
Expand Down

0 comments on commit df5448a

Please sign in to comment.