I've started on a small game where a player click around on a "map" to finish tasks. The user is only allowed to move the player X squares each click. How do I limit the player to not being able to move through blocks?
Right now, it is possible for the player to move through the filled area, but I don't want that to be possible, the user should only be able to move where there are no filled squares. (Ie. the green path.)
Currently I'm calculating the length of the vector between the start point and end point to see if the user can move that far, but i don't know how to check if there's a wall in the way, and then calculate the new length.
(The red path is the shortest way, the green path is the path I'm trying to force the player to walk. The M is the player.)