/** * @class Discrete shadowcasting algorithm * @augments ROT.FOV */ ROT.FOV.DiscreteShadowcasting = function(lightPassesCallback, options) { ROT.FOV.call(this, lightPassesCallback, options); } ROT.FOV.DiscreteShadowcasting.extend(ROT.FOV); /** * @see ROT.FOV#compute */ ROT.FOV.DiscreteShadowcasting.prototype.compute = function(x, y, R, callback) { var center = this._coords; var map = this._map; /* this place is always visible */ callback(x, y, 0); /* standing in a dark place. FIXME is this a good idea? */ if (!this._lightPasses(x, y)) { return; } /* start and end angles */ var DATA = []; var A, B, cx, cy, blocks; /* analyze surrounding cells in concentric rings, starting from the center */ for (var r=1; r<=R; r++) { var neighbors = this._getCircle(x, y, r); var angle = 360 / neighbors.length; for (var i=0;i