Skip to content

Instantly share code, notes, and snippets.

@McFunkypants
Created January 16, 2013 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McFunkypants/4544716 to your computer and use it in GitHub Desktop.
Save McFunkypants/4544716 to your computer and use it in GitHub Desktop.
// Node function, returns a new object with Node properties
// Used in the calculatePath function to store route costs, etc.
function Node(Parent, Point)
{
var newNode = {
// pointer to another Node object
Parent:Parent,
// array index of this Node in the world linear array
value:Point.x + (Point.y * worldWidth),
// the location coordinates of this Node
x:Point.x,
y:Point.y,
// the distanceFunction cost to get
// TO this Node from the START
f:0,
// the distanceFunction cost to get
// from this Node to the GOAL
g:0
};
return newNode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment