-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloatingMessage.js
More file actions
28 lines (25 loc) · 840 Bytes
/
floatingMessage.js
File metadata and controls
28 lines (25 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
export class FloatingMessage{
constructor(game, value, sx, sy, dx, dy){
this.game = game;
this.value = value;
this.sx = sx;
this.sy = sy;
this.dx = dx;
this.dy = dy;
this.timer = 0;
this.markedForDeletion = false;
}
render(ctx){
ctx.font = "15px Arial";
ctx.fillStyle = "gold";
ctx.fillText(this.value, -this.game.camera.viewportX+this.sx, -this.game.camera.viewportY+this.sy);
ctx.fillStyle = "green";
ctx.fillText(this.value, -this.game.camera.viewportX+this.sx+2, -this.game.camera.viewportY+this.sy+2);
}
update(){
this.timer++;
this.sx+= (this.dx - this.sx) * 0.03;
this.sy+= (this.dy - this.sy) * 0.03;
if(this.timer > 100) this.markedForDeletion = true;
}
}