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:
-
game
Game- 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:
-
x
Number- Map tile x coord.
-
y
Number- Map tile y coord.
get
(
-
x
-
y
Retrieves the visibility of the tile at given coords
Parameters:
-
x
Number- The map coordinate position to get Lighting visibility from on the x axis.
-
y
Number- The map coordinate position to get Lighting visibility from on the y axis.
getTileReflectivity
(
-
x
-
y
Returns the reflectivity value of a tile
Parameters:
-
x
Number- Map tile x coord.
-
y
Number- Map tile y coord.
remove
(
-
x
-
y
Parameters:
-
x
Number- Map tile x coord.
-
y
Number- Map tile y coord.
set
(
-
x
-
y
-
r
-
g
-
b
Set a light position and color
Parameters:
-
x
Number- The map coordinate position to set lightin on the x axis.
-
y
Number- The map coordinate position to set lightin on the y axis.
-
r
Number- Red.
-
g
Number- Green.
-
b
Number- Blue.
setSize
(
-
width
-
height
Sets the size of the map to mange Lighting within.
Parameters:
-
width
Number- Width of current map in tiles.
-
height
Number- Height of current map in tiles.
shadeTile
(
TileData
-
x
-
y
-
tileData
Shades tileData using lighting.
Parameters:
-
x
Number- The x map coordinate to shade.
-
y
Number- The y map coordinate to shade.
-
tileData
TileData- The
TileData
object 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.