public/js-roguelike-skeleton/src/lighting-rot.js
function LightingROT(game, settings) {
        settings = settings || {};
        this.game = game;
        this.lightingMap = new RL.Array2d();
        this.lightingMap.set = this.lightingMap.set.bind(this.lightingMap);

        this.checkVisible = this.checkVisible.bind(this);
        this._fov = new ROT.FOV.PreciseShadowcasting(this.checkVisible);

        settings = RL.Util.mergeDefaults({
            range: 5,
            passes: 2,
            emissionThreshold: 100,
        }, settings);

        this.getTileReflectivity = this.getTileReflectivity.bind(this);
        this._lighting = new ROT.Lighting(this.getTileReflectivity, settings);
        this._lighting.setFOV(this._fov);

        // copy instance
        this.ambientLight = this.ambientLight.slice();
    }
function LightingROT(game, settings) {
        settings = settings || {};
        this.game = game;
        this.lightingMap = new RL.Array2d();
        this.lightingMap.set = this.lightingMap.set.bind(this.lightingMap);

        this.checkVisible = this.checkVisible.bind(this);
        this._fov = new ROT.FOV.PreciseShadowcasting(this.checkVisible);

        settings = RL.Util.mergeDefaults({
            range: 5,
            passes: 2,
            emissionThreshold: 100,
        }, settings);

        this.getTileReflectivity = this.getTileReflectivity.bind(this);
        this._lighting = new ROT.Lighting(this.getTileReflectivity, settings);
        this._lighting.setFOV(this._fov);

        // copy instance
        this.ambientLight = this.ambientLight.slice();
    }
function LightingROT ( game , settings ) { settings = settings || { } ; this . game = game ; this . lightingMap = new RL . Array2d ( ) ; this . lightingMap . set = this . lightingMap . set . bind ( this . lightingMap ) ; this . checkVisible = this . checkVisible . bind ( this ) ; this . _fov = new ROT . FOV . PreciseShadowcasting ( this . checkVisible ) ; settings = RL . Util . mergeDefaults ( { range : 5 , passes : 2 , emissionThreshold : 100 , } , settings ) ; this . getTileReflectivity = this . getTileReflectivity . bind ( this ) ; this . _lighting = new ROT . Lighting ( this . getTileReflectivity , settings ) ; this . _lighting . setFOV ( this . _fov ) ; // copy instance this . ambientLight = this . ambientLight . slice ( ) ; }
Represents lighting in the game map. requires ROT.js
Manages position of lights.
Calculates illumination of map tiles.
@class LightingROT
@constructor
@param {Game} game - Game instance this obj is attached to.
@param {Object} [settings] - LightingROT settings object.
@param {Number} [settings.range] - Maximum range for the most powerful light source.
@param {Number} [settings.passes] - Number of computation passes (1: no reflectivity used, 2: reflectivity used)
@param {Number} [settings.emissionThreshold] - Minimal amount of light at a cell to be re-emited (only for passes>1).
Represents lighting in the game map . requires ROT . js Manages position of lights . Calculates illumination of map tiles .