LightingROT Class
Represents lighting in the game map. requires ROT.js Manages position of lights. Calculates illumination of map tiles.
Constructor
LightingROT
(
-
game -
[settings]
Parameters:
-
gameGame- Game instance this obj is attached to.
-
[settings]Object optional- LightingROT settings object.
-
[range]Number optional- Maximum range for the most powerful light source.
-
[passes]Number optional- Number of computation passes (1: no reflectivity used, 2: reflectivity used)
-
[emissionThreshold]Number optional- Minimal amount of light at a cell to be re-emited (only for passes>1).
Item Index
Methods
checkVisible
(
-
x -
y
Checks if a tile blocks line of sight
Parameters:
-
xNumber- Map tile x coord.
-
yNumber- Map tile y coord.
get
(
-
x -
y
Retrieves the visibility of the tile at given coords
Parameters:
-
xNumber- The map coordinate position to get Lighting visibility from on the x axis.
-
yNumber- The map coordinate position to get Lighting visibility from on the y axis.
getTileReflectivity
(
-
x -
y
Returns the reflectivity value of a tile
Parameters:
-
xNumber- Map tile x coord.
-
yNumber- Map tile y coord.
remove
(
-
x -
y
Parameters:
-
xNumber- Map tile x coord.
-
yNumber- Map tile y coord.
set
(
-
x -
y -
r -
g -
b
Set a light position and color
Parameters:
-
xNumber- The map coordinate position to set lightin on the x axis.
-
yNumber- The map coordinate position to set lightin on the y axis.
-
rNumber- Red.
-
gNumber- Green.
-
bNumber- Blue.
setSize
(
-
width -
height
Sets the size of the map to mange Lighting within.
Parameters:
-
widthNumber- Width of current map in tiles.
-
heightNumber- Height of current map in tiles.
shadeTile
(
TileData
-
x -
y -
tileData
Shades tileData using lighting.
Parameters:
-
xNumber- The x map coordinate to shade.
-
yNumber- The y map coordinate to shade.
-
tileDataTileData- The
TileDataobject to shade.
- The
Returns:
TileData:
update
()
Calculates the Lighting data relative to given coords;
Properties
_dirty
Bool
private
If lighting data has changed and needs to be recalculated.
_fov
ROT.FOV
private
ROT.FOV instance
_lighting
ROT.Lighting
private
ROT.Lighting instance
ambientLight
Array
Ambient light
defaultFloorReflectivity
Number
Reflectivity of floor tiles.
defaultWallReflectivity
Number
Reflectivity of wall tiles.
