-
Notifications
You must be signed in to change notification settings - Fork 1
/
box.txt
64 lines (64 loc) · 1.6 KB
/
box.txt
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
53
54
55
56
57
58
59
60
61
62
63
64
function Box(row, column) {
this.domElement = document.getElementById(`${row}${column}`);
if (column > 1) {
this.leftNeighbour = {
domElement: document.getElementById(`${row}${column - 1}`),
weight: 1,
};
}
if (column < 50) {
this.rightNeighbour = {
domElement: document.getElementById(`${row}${column + 1}`),
weight: 1,
};
}
if (row > 1) {
this.upNeighbour = {
domElement: document.getElementById(`${row - 1}${column}`),
weight: 1,
};
}
if (row < 25) {
this.downNeighbour = {
domElement: document.getElementById(`${row + 1}${column}`),
weight: 1,
};
}
if (row > 1 && column > 1) {
this.upLeftNeighbour = {
domElement: document.getElementById(`${row - 1}${column - 1}`),
weight: 1.41,
};
}
if (row > 1 && column < 50) {
this.upRightNeighbour = {
domElement: document.getElementById(`${row + 1}${column + 1}`),
weight: 1.41,
};
}
if (row < 25 && column > 1) {
this.downLeftNeighbour = {
domElement: document.getElementById(`${row + 1}${column - 1}`),
weight: 1.41,
};
}
if (row < 25 && column < 50) {
this.downRightNeighbour = {
domElement: document.getElementById(`${row + 1}${column + 1}`),
weight: 1.41,
};
}
this.allNeighbours = [
this.upNeighbour,
this.downNeighbour,
this.leftNeighbour,
this.rightNeighbour,
this.upLeftNeighbour,
this.upRightNeighbour,
this.downLeftNeighbour,
this.downRightNeighbour,
];
this.neighbours = this.allNeighbours.filter(
(neighbour) => neighbour !== undefined
);
}