-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
31 lines (24 loc) · 889 Bytes
/
main.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
// usada para controlar as repetições
let TIME = 0;
const game = new Game();
// board(sizeOfBoard, cellWidth, cellHeight);
const board = new Board(Math.floor(600/10), 10, 10);
game.addNode(board);
game.start();
// Listeners
game.canvas.addEventListener('click', (e) => {
const boardX = Math.floor(e.offsetX / board.width);
const boardY = Math.floor(e.offsetY / board.height);
board.cells[boardX][boardY].isLiving = true;
});
document.getElementById("stop").disabled = true;
document.getElementById("start").addEventListener("click", (e) => {
document.getElementById("start").disabled = true;
document.getElementById("stop").disabled = false;
board.started = true;
});
document.getElementById("stop").addEventListener("click", (e) => {
document.getElementById("stop").disabled = true;
document.getElementById("start").disabled = false;
board.started = false;
});