Tile

Tile

# new Tile(tileW, tileH, tileX, tileY, isEdge)

Represents a single Tile object to be contained within a Grid.
Parameters:
Name Type Description
tileW number The width of this tile in WC.
tileH number The height of this tile in WC.
tileX number The x coordinate of this tile in WC.
tileY number The y coordinate of this tile in WC.
isEdge boolean The property determining if this tile is on the edge of the Grid its in.
Source:

Methods

# addWall(direction) → {boolean}

Adds the given direction to the walls array for this particular tile.
Parameters:
Name Type Description
direction Direction The direction to add a wall to for this tile.
Source:
Returns:
True if the wall was able to be added, false otherwise.
Type
boolean

# draw(cam)

Draws the tile as visible lines around its bounds. Also draws its texture if it has one and is set to visible.
Parameters:
Name Type Description
cam Camera The Camera object to draw the tile to.
Source:

# getC() → {number}

Used for A* search. Retrieves the cost for the tile.
Source:
Returns:
The total cost of reaching this tile.
Type
number

# getCollision() → {boolean}

Gets the collision property of this tile.
Source:
Returns:
True if this tile has collision on, false otherwise.
Type
boolean

# getD() → {array}

Used for A* search. Returns the direction we took to get to this tile.
Source:
Returns:
Array containing a direction.
Type
array

# getF() → {number}

Used for A* search. Returns the combined total of the tile's cost and heuristic.
Source:
Returns:
The combined total of the tile's cost and heuristic..
Type
number

# getH() → {number}

Used for A* search. Retrieves the given heuristic estimate for the tile.
Source:
Returns:
The estimate to the goal given by a heuristic.
Type
number

# getMoves() → {array}

Gets all the valid moves out of a particular tile. That is, any side of this tile that doesn't have a wall.
Source:
Returns:
All the directional movements possible out of this tile.
Type
array

# getP() → {array}

Used for A* search. Returns the predecessor to this tile. If no predecessor, returns [-1, -1].
Source:
Returns:
Array containing the index of the predecessor tile.
Type
array

# getWalls() → {array}

Gets all the walls currently assigned to this tile.
Source:
Returns:
All the directional walls assigned to this tile.
Type
array

# getXPosWC() → {number}

Gets the x position of the center of the tile in WC.
Source:
Returns:
The x position of the tile center in WC.
Type
number

# getYPosWC() → {number}

Gets the y position of the center of the tile in WC.
Source:
Returns:
The y position of the tile center in WC.
Type
number

# hasP() → {boolean}

Method used during A* search. Determines if this tile has a predecessor tile or not.
Source:
Returns:
Whether this tile has a predecessor tile or not.
Type
boolean

# isVisible() → {boolean}

Gets the visibility property of this tile.
Source:
Returns:
True if this tile is set to visible, false otherwise.
Type
boolean

# readySearch()

Resets any data stored from previous A* searches to their default values.
Source:

# removeWall(direction) → {boolean}

Removes the given direction to the walls array for this particular tile.
Parameters:
Name Type Description
direction Direction The direction to remove a wall to for this tile.
Source:
Returns:
True if the wall was able to be removed, false otherwise.
Type
boolean

# setC(c)

Used for A* search. Sets the cost for the tile.
Parameters:
Name Type Description
c number The total cost of reaching this tile.
Source:

# setCollision(bool)

Sets the collision property of this tile.
Parameters:
Name Type Description
bool boolean The value to set the collision property of this tile to.
Source:

# setD(d)

Used for A* search. Sets the direction we took to get to this tile.
Parameters:
Name Type Description
d array Array containing a direction.
Source:

# setGridLineVisibility(setTo)

Sets the visibility property of the grid lines around this tile.
Parameters:
Name Type Description
setTo boolean The value to set the grid line visibility to.
Source:

# setH(h)

Used for A* search. Stores the given heuristic estimate for the tile.
Parameters:
Name Type Description
h number The estimate to the goal given by a heuristic.
Source:

# setP(p)

Used for A* search. Sets the predecessor to this tile.
Parameters:
Name Type Description
p array Array containing the index of the predecessor tile.
Source:

# setTexture(texture)

Sets the texture for this tile to the texture corresponding to a given filepath.
Parameters:
Name Type Description
texture String The filepath to an already loaded texture to set the tile to contain.
Source:

# setVisible(setTo) → {boolean}

Sets the visibility of the tile. Cannot set a tile to visible if it doesn't have an assigned texture.
Parameters:
Name Type Description
setTo boolean The value to set the visibility property to.
Source:
Returns:
True if the settting was successful, false otherwise.
Type
boolean

# setWallVisibility(setTo)

Sets the visibility property of the wall lines around this tile.
Parameters:
Name Type Description
setTo boolean The value to set the wall line visibility to.
Source: