Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
titaniumnetwork-dev
GitHub Repository: titaniumnetwork-dev/Incognito-old
Path: blob/main/static/src/gs/public/radius-raid/js/particleemitter.js
1338 views
1
/*==============================================================================
2
Init
3
==============================================================================*/
4
$.ParticleEmitter = function( opt ) {
5
for( var k in opt ) {
6
this[k] = opt[k];
7
}
8
this.particles = [];
9
for( var i = 0; i < this.count; i++ ) {
10
var radius = Math.sqrt( Math.random() ) * this.spawnRange,
11
angle = Math.random() * $.twopi,
12
x = this.x + Math.cos( angle ) * radius,
13
y = this.y + Math.sin( angle ) * radius;
14
this.particles.push( new $.Particle( {
15
parent: this.particles,
16
x: x,
17
y: y,
18
speed: $.util.rand( this.minSpeed, this.maxSpeed ),
19
friction: this.friction,
20
direction: $.util.rand( this.minDirection, this.maxDirection ),
21
lineWidth: $.util.rand( 0.5, 1.5 ),
22
hue: this.hue,
23
saturation: this.saturation
24
} ) );
25
}
26
};
27
28
/*==============================================================================
29
Update
30
==============================================================================*/
31
$.ParticleEmitter.prototype.update = function( i ) {
32
var i2 = this.particles.length; while( i2-- ){ this.particles[ i2 ].update( i2 ) }
33
if( this.particles.length <= 0 ) {
34
$.particleEmitters.splice( i, 1 );
35
}
36
};
37
38
/*==============================================================================
39
Render
40
==============================================================================*/
41
$.ParticleEmitter.prototype.render = function( i ) {
42
var i2 = this.particles.length; while( i2-- ){ this.particles[ i2 ].render( i2 ) }
43
};
44