❔ How do I get the direction between two points?

Say that you are at position (10, 10) on the map, and your destination is (2, 2). I would like to calculate this and output this: "You need to go northwest." There will be all other directions, too. In my program, my Array2D class is being used to store the 2d array, and (0,0) is at the top-left corner.

My function is currently this, assuming I need vectors for it. What do I need to do to achieve this?

        public EDirection GetDirection(int xPos, int yPos, int xDest, int yDest)
        {
            Vector2D pos = new Vector2D(xPos, yPos);
            Vector2D dest = new Vector2D(xDest, yDest);


        }
Was this page helpful?