Skip to content

Commit

Permalink
✨ droplets when landing on pad
Browse files Browse the repository at this point in the history
  • Loading branch information
haliphax committed Dec 1, 2023
1 parent f6bd76a commit 39861ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import WebFontFile from "./webfontfile";
export default class Game extends Phaser.Scene {
active: boolean;
dropGroup: Phaser.Physics.Arcade.Group | null;
droplets!: Phaser.GameObjects.Particles.ParticleEmitter;
droppers: Map<string, Avatar>;
droppersArray: Array<Avatar>;
droppersQueue: Set<string>;
Expand Down Expand Up @@ -64,6 +65,10 @@ export default class Game extends Phaser.Scene {
this.load.image("drop4", "drop4.png");
this.load.image("drop5", "drop5.png");
this.load.image("pad", "pad.png");
this.load.spritesheet("droplet", "droplet.png", {
frameHeight: 82,
frameWidth: 82,
});
}

create() {
Expand All @@ -76,6 +81,16 @@ export default class Game extends Phaser.Scene {
.setOrigin(0.5, 1)
.setVisible(false)
.setPosition(0, constants.SCREEN_HEIGHT);
this.droplets = this.add
.particles(0, 0, "droplet", {
blendMode: Phaser.BlendModes.ADD,
emitting: false,
gravityY: -500,
lifespan: 500,
scale: { start: 1, end: 0.2 },
speed: { random: [50, 150] },
})
.setDepth(1);
this.ready();
}

Expand Down Expand Up @@ -137,7 +152,7 @@ export default class Game extends Phaser.Scene {
drop.update();
}

this.rect?.setPosition(this.pad?.x, this.pad?.y);
this.rect?.setPosition(this.pad!.x, this.pad!.y);
}

tidyScores() {
Expand Down Expand Up @@ -235,6 +250,11 @@ export default class Game extends Phaser.Scene {
return;
}

this.droplets.emitParticleAt(
avatar.container.x,
avatar.container.y + avatar.sprite.height / 2,
20,
);
this.resetTimer();
avatar.swayTween?.stop();
avatar.swayTween = null;
Expand Down
Binary file added src/public/default/droplet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 39861ba

Please sign in to comment.