forked from vlzhr/beet-js-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Counter.js
55 lines (47 loc) · 1.72 KB
/
Counter.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
51
52
document.addEventListener("DOMContentLoaded", function () {
window.counter = {
coinsNode: document.querySelector(".coins-value"),
metersNode: document.querySelector(".distance-value"),
coinsValue: 0,
metersValue: 0,
coinsPlus: function() {
this.coinsValue ++;
this.coinsNode.innerHTML = this.coinsValue;
},
metersPlus: function() {
this.metersValue ++;
this.metersNode.innerHTML = this.metersValue;
},
toNull() {
this.coinsValue = 0;
this.metersValue = 0;
this.coinsNode.innerHTML = this.coinsValue;
this.metersNode.innerHTML = this.metersValue;
}
};
window.winscreen = {
node: document.querySelector(".winscreen"),
scoreNode: document.querySelector(".winscreen__score-value"),
coinsNode: document.querySelector(".winscreen__coins-value"),
metersNode: document.querySelector(".winscreen__distance-value"),
show: function() {
this.coinsNode.innerHTML = counter.coinsValue;
this.metersNode.innerHTML = counter.metersValue;
this.scoreNode.innerHTML = counter.metersValue + counter.coinsValue*6;
setTimeout(() => {
beet.alpha = 0;
for (let k of enemies) {
k.alpha = 0;
}
this.node.classList.add("shown");
}, 700);
setTimeout(function() {
console.log("log");
game.touchListener = function() {
winscreen.node.remove();
location.reload();
};
}, 2500)
}
};
});