-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (37 loc) · 1021 Bytes
/
app.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
var cells = [];
var bombCount = 3
var cellCount = 26;
var neededToWin = cellCount-bombCount;
function setup() {
createCanvas(600, 600);
let gridSize = 8;
let cellSize = 50;
let field = [["x","1","0","0","0","0"],
["1","2","1","2","1","1"],
["0","1","x","2","x","1"],
["0","1","1","2","1","1"]];
for(let i = 0; i<field.length; i++){
for(let j = 0; j<field[i].length; j++){
let color;
if(field[i][j] == "x"){
color = "#ff384b";
}else if(field[i][j] == "0"){
color = "#fff";
}else{
color = "#000";
}
let cell = new Cell(0+(cellSize*j),0+(cellSize*i), cellSize, color, field[i][j]);
cells.push(cell);
}
}
}
draw = () => {
for(let i = 0; i<cells.length; i++){
cells[i].show();
}
}
mousePressed = () => {
for(let i = 0; i<cells.length; i++){
cells[i].clicked();
}
}