Skip to content

Commit

Permalink
Snow for real
Browse files Browse the repository at this point in the history
  • Loading branch information
roboyeti committed Jan 5, 2023
1 parent 4c89b9a commit ebc8a57
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions fx/chill/chill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
class Chill extends Phaser.Scene {
constructor (config={}) {
super(config);
}

preload() {
this.load.image('snow', './fx/chill/snowflake02.png');
// this.load.audio('wind', ['./fx/images/Pop-sound.mp3',]);
this.w = window.innerWidth
this.h = window.innerHeight
}

create() {
this.flake1 = this.add.particles('snow');
var SECOND = 1000;
var highWind = {
tween: this.tweens.addCounter({
from:-3,
to: 10,
duration: 6 * SECOND,
loop: Phaser.FOREVER,
ease: 'Sine.easeInOut'
}),
processor: {
active: true,
update: function (particle)
{
particle.velocityX += highWind.tween.getValue();
}
}
};

var lowWind = {
tween: this.tweens.addCounter({
from:0,
to: 3,
duration: 3 * SECOND,
loop: Phaser.FOREVER,
ease: 'Sine.easeInOut'
}),
processor: {
active: true,
update: function (particle)
{
particle.velocityY += lowWind.tween.getValue();
}
}
};

var conf = {
x: { min: -500, max: this.w + 500 },
y: { min: -50, max: -50 }, //this.h/2,
lifespan: 6000,
speed: { min: 100, max: 150},
rotate: {min: -360, max: 360},
scaleX: { start: 0.05, end: 0.01 },
scaleY: { start: 0.06, end: 0.01 },

// scaleX: { min: 0.01, max: 0.02 },
// scaleY: { min: 0.01, max: 0.02 },
// scaleX: { min: 0.01, max: 0.2 },
// scaleY: { min: -1, max: 1 },

alpha: { start: 0.8, end: 0 },
gravityY: 100,
blendMode: 'SCREEN',
frequency: 1,
// quantity: 10,
// maxParticles: 1200,
tint: [ 0xFFFFFF, 0xDDDDFF ]
}

this.flake1.addGravityWell(highWind.processor);
this.flake1.addGravityWell(lowWind.processor);
this.emito = this.flake1.createEmitter(conf);

// var a = this.sound.add('confetti');
// a.detune = getRndInteger(-300,300)
// a.play();

setTimeout(()=>{
this.emito.stop();
setTimeout( (t)=> {
console.log('Chill cleanup...')
t.flake1.scene.scene.remove();
},4000,this)
},6500)
}

}
Binary file added fx/chill/snowflake01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fx/chill/snowflake02.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 ebc8a57

Please sign in to comment.