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
Golen87 committed Nov 19, 2023
2 parents 42eace8 + e63fb5f commit 48dba55
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/Turtle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export class Turtle extends Button {
// Stop fall
this.physicsVelocity.y = 0;
this.physicsPosition.y = this.border.bottom - this.feetOffset;

if (this.lostBalance && !this.hasCrashed) {
this.hasCrashed = true;
this.scene.addDust(this.x+this.sprite.x, this.y+this.sprite.y);
this.emit("crashed");
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/scenes/GameScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export class GameScene extends BaseScene {
this.ui.update(time, delta);
}

addDust(x: number, y: number)
{
this.overworld.addDust(x,y);
}

setState(state: State) {
this.state = state;
this.events.emit(`state_${state}`);
Expand Down
15 changes: 15 additions & 0 deletions src/scenes/OverworldState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ export class OverworldState extends Phaser.GameObjects.Container {
this.someButton.on("click", () => {
this.scene.setState(State.Shop);
});
const expl = {
key: 'dust_explosion',
frames: 'dust',
frameRate: 12,
showOnStart: true,
hideOnComplete: true,
};

this.scene.anims.create(expl);
}

update(time: number, delta: number) {
Expand All @@ -68,6 +77,12 @@ export class OverworldState extends Phaser.GameObjects.Container {
});
}

addDust(x: number, y: number)
{
let xpl = this.scene.add.sprite(x, y, 'dust_explosion');
xpl.play({ key: 'dust_explosion', delay: 0 });
}

addTurtle() {
let x = this.scene.W * (0.5 + 0.4 * Math.random());
let y = this.scene.H * (0.6 + 0.2 * Math.random());
Expand Down

0 comments on commit 48dba55

Please sign in to comment.