Constructor
new Cell(index, visitedopt)
Initialize a cell object.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
index |
GridIndex |
|
||
visited |
boolean |
<optional> |
false | If the cell has been visited or not. |
Extends
Members
down
Properties:
Name | Type | Description |
---|---|---|
down |
boolean | Bottom-side wall of the box. |
index
Properties:
Name | Type | Description |
---|---|---|
index |
GridIndex | Position on a 2D grid. |
left
Properties:
Name | Type | Description |
---|---|---|
left |
boolean | Left-side wall of the box. |
right
Properties:
Name | Type | Description |
---|---|---|
right |
boolean | Right-side wall of the box. |
up
Properties:
Name | Type | Description |
---|---|---|
up |
boolean | Top-side wall of the box. |
visited
Properties:
Name | Type | Description |
---|---|---|
visited |
boolean | If the cell has been visited or not. |
Methods
getNeighborIndices() → {Map.<string, GridIndex>}
Fetch all the possible adjacent neighbors on a grid based off of the cell's position.
Returns:
- A map of each adjacent neighbor keyed to the respective direction of that neighbor.
- Type
- Map.<string, GridIndex>
setWalls(enable)
Sets all of the walls either on or off.
Parameters:
Name | Type | Description |
---|---|---|
enable |
boolean | To toggle on or off. |
- Overrides:
- Source:
toggleOpposite(wall, enable)
Wrapper method to change the visibility of the opposite Wall
in the box based off of a string.
Felt much easier to just use a switch statement here rather than reuse Box.toggleWall
.
Parameters:
Name | Type | Description |
---|---|---|
wall |
Box.WALLS | What wall that will be the opposite of the toggled wall. |
enable |
boolean | To toggle on or off. |
- Overrides:
- Source:
Example
Box.toggleOpposite('LEFT', true) // Toggles the right wall on.
toggleWall(wall, enable)
Wrapper method to change the visibility of a given Wall
in the box based off of a string.
Parameters:
Name | Type | Description |
---|---|---|
wall |
Box.WALLS | What wall to toggle. |
enable |
boolean | To toggle on or off. |
- Overrides:
- Source: