-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc_functions.js
43 lines (35 loc) · 967 Bytes
/
misc_functions.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
"use strict";
function updateScore() {
ctx.clearRect(0, 0, 155, 21);
scoreText.text = `Score: ${score}`;
scoreText.draw(ctx);
}
const randomNum = (min, max) => { return Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min) + 1) + Math.ceil(min)) };
function checkGameOver() {
if(wall.hp <= 0) {
scoreElem.innerHTML = `Score: ${score}`;
messageElem.innerHTML = "Game Over";
gameOverElem.style.display = "block";
running = false;
clearInterval(_interval);
}
}
function checkWin() {
if (currentLevel > levels.length) {
scoreElem.innerHTML = `Score: ${score}`;
messageElem.innerHTML = "You Win!";
gameOverElem.style.display = "block";
running = false;
clearInterval(_interval);
}
}
function pauseGame() {
shopElem.style.display = "block";
running = false;
shopOpen = true;
}
function unpauseGame() {
shopElem.style.display = "none";
running = true;
shopOpen = false;
}