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/textpop.js
1338 views
1
/*==============================================================================
2
Init
3
==============================================================================*/
4
$.TextPop = function( opt ) {
5
for( var k in opt ) {
6
this[k] = opt[k];
7
}
8
this.alpha = 2;
9
this.vy = 0;
10
};
11
12
/*==============================================================================
13
Update
14
==============================================================================*/
15
$.TextPop.prototype.update = function( i ) {
16
this.vy -= 0.05;
17
this.y += this.vy * $.dt;
18
this.alpha -= 0.03 * $.dt;
19
20
if( this.alpha <= 0 ){
21
$.textPops.splice( i, 1 );
22
}
23
};
24
25
/*==============================================================================
26
Render
27
==============================================================================*/
28
$.TextPop.prototype.render = function( i ) {
29
$.ctxmg.beginPath();
30
$.text( {
31
ctx: $.ctxmg,
32
x: this.x,
33
y: this.y,
34
text: '+' + this.value,
35
hspacing: 1,
36
vspacing: 0,
37
halign: 'center',
38
valign: 'center',
39
scale: 2,
40
snap: 0,
41
render: 1
42
} );
43
$.ctxmg.fillStyle = 'hsla(' + this.hue + ', ' + this.saturation + '%, ' + this.lightness + '%, ' + this.alpha + ')';
44
$.ctxmg.fill();
45
}
46