Path: blob/main/static/src/gs/public/radius-raid/js/particle.js
1330 views
/*==============================================================================1Init2==============================================================================*/3$.Particle = function( opt ) {4for( var k in opt ) {5this[k] = opt[k];6}7};89/*==============================================================================10Update11==============================================================================*/12$.Particle.prototype.update = function( i ) {13/*==============================================================================14Apply Forces15==============================================================================*/16this.x += Math.cos( this.direction ) * ( this.speed * $.dt );17this.y += Math.sin( this.direction ) * ( this.speed * $.dt );18this.ex = this.x - Math.cos( this.direction ) * this.speed;19this.ey = this.y - Math.sin( this.direction ) * this.speed;20this.speed *= this.friction;2122/*==============================================================================23Lock Bounds24==============================================================================*/25if( !$.util.pointInRect( this.ex, this.ey, 0, 0, $.ww, $.wh ) || this.speed <= 0.05 ) {26this.parent.splice( i, 1 );27}2829/*==============================================================================30Update View31==============================================================================*/32if( $.util.pointInRect( this.ex, this.ey, -$.screen.x, -$.screen.y, $.cw, $.ch ) ) {33this.inView = 1;34} else {35this.inView = 0;36}37};3839/*==============================================================================40Render41==============================================================================*/42$.Particle.prototype.render = function( i ) {43if( this.inView ) {44$.ctxmg.beginPath();45$.ctxmg.moveTo( this.x, this.y );46$.ctxmg.lineTo( this.ex, this.ey );47$.ctxmg.lineWidth = this.lineWidth;48$.ctxmg.strokeStyle = 'hsla(' + this.hue + ', ' + this.saturation + '%, ' + $.util.rand( 50, 100 ) + '%, 1)';49$.ctxmg.stroke();50}51}5253