Path: blob/main/static/src/gs/public/radius-raid/js/particleemitter.js
1338 views
/*==============================================================================1Init2==============================================================================*/3$.ParticleEmitter = function( opt ) {4for( var k in opt ) {5this[k] = opt[k];6}7this.particles = [];8for( var i = 0; i < this.count; i++ ) {9var radius = Math.sqrt( Math.random() ) * this.spawnRange,10angle = Math.random() * $.twopi,11x = this.x + Math.cos( angle ) * radius,12y = this.y + Math.sin( angle ) * radius;13this.particles.push( new $.Particle( {14parent: this.particles,15x: x,16y: y,17speed: $.util.rand( this.minSpeed, this.maxSpeed ),18friction: this.friction,19direction: $.util.rand( this.minDirection, this.maxDirection ),20lineWidth: $.util.rand( 0.5, 1.5 ),21hue: this.hue,22saturation: this.saturation23} ) );24}25};2627/*==============================================================================28Update29==============================================================================*/30$.ParticleEmitter.prototype.update = function( i ) {31var i2 = this.particles.length; while( i2-- ){ this.particles[ i2 ].update( i2 ) }32if( this.particles.length <= 0 ) {33$.particleEmitters.splice( i, 1 );34}35};3637/*==============================================================================38Render39==============================================================================*/40$.ParticleEmitter.prototype.render = function( i ) {41var i2 = this.particles.length; while( i2-- ){ this.particles[ i2 ].render( i2 ) }42};4344