In the previous chapter, we added event handlers and logic to move the player around the map. But so far, the player can walk across trees and vehicles and go outside the map. In this chapter, we are going to make sure that the player can’t take an invalid position.
We will check if a move is valid by calculating where it would take the player. If the player would end up outside the map or on a tile occupied by a tree, we will ignore that move.