-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHexTile.js
32 lines (28 loc) · 785 Bytes
/
HexTile.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
/**
* Object for storing information about our hexagons.
*/
export default class HexTile {
constructor(gridPosition, hexSize) {
[this.row, this.col] = gridPosition;
this.width = hexSize.width;
this.height = hexSize.height;
this.isStart = false;
this.isEnd = false;
this.isWall = false;
this.fill = 'white';
if (this.col % 2 === 0) {
this.xPos = (this.col / 2) * (this.width * 3);
this.yPos = this.height + this.row * (2 * this.height);
} else {
this.xPos =
this.width * (3 / 2) + ((this.col - 1) / 2) * (this.width * 3);
this.yPos = 2 * this.height + this.row * (2 * this.height);
}
}
reset() {
this.isStart = false;
this.isEnd = false;
this.isWall = false;
this.fill = 'white';
}
}