API Docs for:
Show:

FovROT Class

Defined in: src/fov-rot.js:4

Represents a FovROT in the game map. requires ROT.js

Constructor

FovROT

(
  • game
)

Defined in src/fov-rot.js:4

Parameters:

  • game Game
    • Game instance this obj is attached to.

Methods

directionStringToArray

(
  • direction
)
Array

Defined in src/fov-rot.js:83

Converts a string direction to an rot direction

Parameters:

  • direction String
    • Direction of fov (used as default) (not used for fieldRange 360) valid directions: ['up', 'down', 'left', 'right', 'up_left', 'up_right', 'down_left', 'down_right'].

Returns:

Array:

[x, y]

entityCanSeeThrough

(
  • entity
)
Function

Defined in src/fov-rot.js:156

Checks if a tile blocks line of sight

Parameters:

  • entity Entity
    • The entity to make a callback for.

Returns:

Function:

get

(
  • x
  • y
)
Bool

Defined in src/fov-rot.js:145

Retrieves the visibility of the tile at given coords

Parameters:

  • x Number
    • The map coord position to get FovROT visibility from.
  • y Number
    • The map coord position to get FovROT visibility from.

Returns:

Bool:

setMapTileVisible

(
  • x
  • y
  • range
  • visibility
)

Defined in src/fov-rot.js:169

Sets the visibility of a checked map tile

Parameters:

  • x Number
    • The map coord position to set.
  • y Number
    • The map coord position to set.
  • range Number
    • The distance from this fov origin.
  • visibility Number
    • The visibility of this tile coord.

setSize

(
  • width
  • height
)

Defined in src/fov-rot.js:197

Sets the size of the map to mange fovROT within.

Parameters:

  • width Number
    • Width of current map in tiles.
  • height Number
    • Height of current map in tiles.

update

(
  • x
  • y
  • [fieldRange
  • [direction
  • [maxViewDistance
  • [entity]
)

Defined in src/fov-rot.js:94

Calculates the fovROT data relative to given coords.

Parameters:

  • x Number
    • The map coordinate position to calculate FovROT from on the x axis.
  • y Number
    • The map coordinate position to calculate FovROT from on the y axis.
  • [fieldRange Number

    = this.fieldRange || 360] - Field Range of view 90, 180, or 360.

  • [direction String | ROT.DIRS8.x

    = this.direction || 'up'] - Direction of fov (not used for fieldRange 360) valid directions: ['up', 'down', 'left', 'right', 'up_left', 'up_right', 'down_left', 'down_right'];.

  • [maxViewDistance Number

    = this.maxViewDistance] - Max visible distance in tiles.

  • [entity] Entity optional
    • The entity to check tile visibility with.

validateFieldRange

(
  • fieldRange
)

Defined in src/fov-rot.js:71

Validates a fieldRange value.

Parameters:

  • fieldRange Number
    • Field Range of view valid values: 90, 180, or 360.

Properties

direction

String

Defined in src/fov-rot.js:41

Direction of fov (used as default) (not used for fieldRange 360) valid directions: ['up', 'down', 'left', 'right', 'up_left', 'up_right', 'down_left', 'down_right'].

fieldRange

Number

Defined in src/fov-rot.js:34

Field Range of view 90, 180, or 360.

fovMap

Array2d

Defined in src/fov-rot.js:27

Array2d storing fovROT visibility fovMap

game

Game

Defined in src/fov-rot.js:20

Game instance this obj is attached to.

maxViewDistance

Number

Defined in src/fov-rot.js:48

Max visible distance in tiles

visibleTileKeys

Array private

Defined in src/fov-rot.js:63

Array of visible tile keys used to prevent duplicates in this.visibleTiles.

visibleTiles

Array

Defined in src/fov-rot.js:55

All visible map tiles Array of objects: {x: null, y: null, tile: null, range: null}