-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.js
43 lines (36 loc) · 895 Bytes
/
Board.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
class Board {
constructor() {
this.fontColor = "white";
}
getMousePosition(event) {
let rect = canvas.getBoundingClientRect();
let position = {
x: event.clientX - rect.left,
y: event.clientY - rect.top,
};
return position;
}
clear() {
ctx.clearRect(0, 0, width, height);
}
startScreen() {
ctx.fillStyle = this.fontColor;
ctx.font = "20px Arial";
ctx.fillText("PYTHON 🐍", width / 2 - 45, height / 2 - 50);
}
highScore() {
// let highScore = JSON.parse(localStorage.getItem("python_game") || 0);
ctx.font = "12px Arial";
ctx.fillStyle = this.fontColor;
ctx.fillText(
`High Score is: ${highScore}`,
width / 2 - 45,
height / 2 + 60
);
}
scoreBoard(score) {
ctx.fillStyle = this.fontColor;
ctx.font = "12px Arial";
ctx.fillText(`Score: ${score}`, width - 80, 40);
}
}