A* path finding

When each node takes only 1 to move between (A flat cost map) then you don’t need to do anything. It’s when you have maps of different costs (Say, moving from a road to a swamp in a strategy game, or going up stairs or something) then you have to worry about it.

What you can do when it comes to the out of bounds things is use some method call to get the nodes:


private static Node nullNode = new Node(-1, -1);
public Node getNode(Node parent, int x, int y) {
if(x < 0 || x >= boundsX || y < 0 || y >= boundsY) {
return nullNode
} else {
return new Node(parent, x, y);
}
}