lychees's picture
Upload 569 files
87b3b3a
/**
* @class Abstract pathfinder
* @param {int} toX Target X coord
* @param {int} toY Target Y coord
* @param {function} passableCallback Callback to determine map passability
* @param {object} [options]
* @param {int} [options.topology=8]
*/
ROT.Path = function(toX, toY, passableCallback, options) {
this._toX = toX;
this._toY = toY;
this._fromX = null;
this._fromY = null;
this._passableCallback = passableCallback;
this._options = {
topology: 8
}
for (var p in options) { this._options[p] = options[p]; }
this._dirs = ROT.DIRS[this._options.topology];
}
/**
* Compute a path from a given point
* @param {int} fromX
* @param {int} fromY
* @param {function} callback Will be called for every path item with arguments "x" and "y"
*/
ROT.Path.prototype.compute = function(fromX, fromY, callback) {
}
ROT.Path.prototype._getNeighbors = function(cx, cy) {
var result = [];
for (var i=0;i<this._dirs.length;i++) {
var dir = this._dirs[i];
var x = cx + dir[0];
var y = cy + dir[1];
if (!this._passableCallback(x, y)) { continue; }
result.push([x, y]);
}
return result;
}