-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.js
50 lines (46 loc) · 1.24 KB
/
ui.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class MenuBar {
/**
*
* @param {Player} player
*/
constructor(player) {
this.width = 200;
this.height = screen.height;
this.player = player;
this.startX = screen.width / 2 + 50;
this.startY = -screen.height / 2;
this.color = color(29, 30, 32)
}
run() {
this.draw();
}
draw() {
push();
stroke("black")
// stroke(29, 30, 32, 0);
fill(this.color)
translate(player.location.x, player.location.y);
rect(this.startX, this.startY, this.width, this.height);
this.drawStats();
pop();
}
drawStats() {
fill(255);
stroke(255);
textSize(14);
textFont(fontMontserrat);
let column = { x1: this.startX + 10, y1: this.startY + 20 };
let rowValue = 0;
let stats = [
{ label: "x: ", value: round(this.player.location.x, 0) },
{ label: "y: ", value: round(this.player.location.y, 0) },
{ label: "attackSpeed: ", value: round(this.player.attackSpeed, 0) },
{ label: "velocity: ", value: round(this.player.velocity.mag(), 0) },
{ label: "fps: ", value: round(frameRate(), 0) },
];
for (let i = 0; i < stats.length; i++) {
text(stats[i].label + stats[i].value, column.x1, column.y1 + rowValue);
rowValue += 15;
}
}
}