Path: blob/main/static/src/gs/public/radius-raid/js/levelpop.js
1325 views
/*==============================================================================1Init2==============================================================================*/3$.LevelPop = function( opt ) {4for( var k in opt ) {5this[k] = opt[k];6}7this.x = $.cw - 20;8this.y = $.ch - 20;9this.tick = 0;10this.tickMax = 240;11this.baseAlpha = 0.2;12if( $.tick != 0 ) {13$.audio.play( 'levelup' );14}15};1617/*==============================================================================18Update19==============================================================================*/20$.LevelPop.prototype.update = function( i ) {21if( this.tick >= this.tickMax ) {22$.levelPops.splice( i, 1 );23} else {24this.tick += $.dt;25}26};2728/*==============================================================================29Render30==============================================================================*/31$.LevelPop.prototype.render = function( i ) {32$.ctxmg.beginPath();33$.text( {34ctx: $.ctxmg,35x: this.x,36y: this.y,37text: $.util.pad( this.level, 2 ),38hspacing: 3,39vspacing: 0,40halign: 'right',41valign: 'bottom',42scale: 12,43snap: 1,44render: 145} );46if( this.tick < this.tickMax * 0.25 ) {47var alpha = ( this.tick / ( this.tickMax * 0.25 ) ) * this.baseAlpha;48} else if( this.tick > this.tickMax - this.tickMax * 0.25 ) {49var alpha = ( ( this.tickMax - this.tick ) / ( this.tickMax * 0.25 ) ) * this.baseAlpha;50} else {51var alpha = this.baseAlpha;52}53alpha = Math.min( 1, Math.max( 0, alpha ) );5455$.ctxmg.fillStyle = 'hsla(0, 0%, 100%, ' + alpha + ')';56$.ctxmg.fill();57}5859