O'Reilly logo

XNA 4.0 Game Development by Example Beginner's Guide by Kurt Jaegers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - adjacent squares

  1. Add the findAdjacentNodes() method to the Helper Methods region of the PathFinder class:
    static private List<PathNode> findAdjacentNodes( PathNode currentNode, PathNode endNode) { List<PathNode> adjacentNodes = new List<PathNode>(); int X = currentNode.GridX; int Y = currentNode.GridY; bool upLeft = true; bool upRight = true; bool downLeft = true; bool downRight = true; if ((X > 0) && (!TileMap.IsWallTile(X - 1, Y))) { adjacentNodes.Add(new PathNode( currentNode, endNode, new Vector2(X - 1, Y), CostStraight + currentNode.DirectCost)); } else { upLeft = false; downLeft = false; } PathFinder classPathFinder classfindAdjacentNodes() method, addingif ((X < 49) && (!TileMap.IsWallTile(X + 1, Y))) { adjacentNodes.Add(new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required