UNPKG

emyrk-pathfinding

Version:

Comprehensive pathfinding library for grid based games

34 lines (32 loc) 966 B
/** * A node in grid. * This class holds some basic information about a node and custom * attributes may be added, depending on the algorithms' needs. * @constructor * @param {number} x - The x coordinate of the node on the grid. * @param {number} y - The y coordinate of the node on the grid. * @param {boolean} [walkable] - Whether this node is walkable. */ function Node(x, y, walkable, weight) { /** * The x coordinate of the node on the grid. * @type number */ this.x = x; /** * The y coordinate of the node on the grid. * @type number */ this.y = y; /** * Whether this node can be walked through. * @type boolean */ this.walkable = (walkable === undefined ? true : walkable); /** * weight multiplier of this node. * @type number (defaults to 1) */ this.weight = (weight === undefined ? 1 : weight); } module.exports = Node;