-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScore.js
36 lines (30 loc) · 780 Bytes
/
Score.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
class Score {
/**
* @type {GameScene}
*/
_scene = null;
/**
* @type {GameElement}
*/
_gameElement = null;
_points = 0;
constructor(scene) {
this._scene = scene;
this.mount();
}
mount() {
const domElement = document.createElement("div");
domElement.id = "score";
domElement.innerHTML = this.points.toString().padStart(8, "0");
const scoreElement = new GameElement(domElement);
this._scene.renderGameElement(scoreElement);
this._gameElement = scoreElement;
}
get points() {
return this._points;
}
set points(value) {
this._points = value;
this._gameElement.setContent(Math.floor(value).toString().padStart(8, "0"));
}
}