Time for action – beginning the implementation of A*

  1. Add a new class called PathFinder to the Robot Rampage project.
  2. Add the following using directive to the top of the class file:
    using Microsoft.Xna.Framework;
  3. Modify the class declaration to make the class static:
    static class PathFinder
  4. Add declarations to the PathFinder class:
    #region Declarations
    private enum NodeStatus { Open, Closed };
    
    private static Dictionary<Vector2, NodeStatus> nodeStatus = 
        new Dictionary<Vector2, NodeStatus>();
    
    private const int CostStraight = 10;
    private const int CostDiagonal = 15;
    
    private static List<PathNode> openList = new List<PathNode>();
    
    private static Dictionary<Vector2, float> nodeCosts = 
        new Dictionary<Vector2, float>();
    #endregion
  5. Create a region in the PathFinder ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.