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/levelpop.js
1325 views
1
/*==============================================================================
2
Init
3
==============================================================================*/
4
$.LevelPop = function( opt ) {
5
for( var k in opt ) {
6
this[k] = opt[k];
7
}
8
this.x = $.cw - 20;
9
this.y = $.ch - 20;
10
this.tick = 0;
11
this.tickMax = 240;
12
this.baseAlpha = 0.2;
13
if( $.tick != 0 ) {
14
$.audio.play( 'levelup' );
15
}
16
};
17
18
/*==============================================================================
19
Update
20
==============================================================================*/
21
$.LevelPop.prototype.update = function( i ) {
22
if( this.tick >= this.tickMax ) {
23
$.levelPops.splice( i, 1 );
24
} else {
25
this.tick += $.dt;
26
}
27
};
28
29
/*==============================================================================
30
Render
31
==============================================================================*/
32
$.LevelPop.prototype.render = function( i ) {
33
$.ctxmg.beginPath();
34
$.text( {
35
ctx: $.ctxmg,
36
x: this.x,
37
y: this.y,
38
text: $.util.pad( this.level, 2 ),
39
hspacing: 3,
40
vspacing: 0,
41
halign: 'right',
42
valign: 'bottom',
43
scale: 12,
44
snap: 1,
45
render: 1
46
} );
47
if( this.tick < this.tickMax * 0.25 ) {
48
var alpha = ( this.tick / ( this.tickMax * 0.25 ) ) * this.baseAlpha;
49
} else if( this.tick > this.tickMax - this.tickMax * 0.25 ) {
50
var alpha = ( ( this.tickMax - this.tick ) / ( this.tickMax * 0.25 ) ) * this.baseAlpha;
51
} else {
52
var alpha = this.baseAlpha;
53
}
54
alpha = Math.min( 1, Math.max( 0, alpha ) );
55
56
$.ctxmg.fillStyle = 'hsla(0, 0%, 100%, ' + alpha + ')';
57
$.ctxmg.fill();
58
}
59