Placing the towers
When the player buys a tower, they have the possibility to place it where they want. In order to include this feature inside our game, we need to make some changes to our towers.
Allowed areas
To begin with, we should notice that the player is not free to place their towers wherever they want to on the map. In fact, they cannot place them along the path where the enemies are moving or in areas where there is water. Therefore, we need to implement this constraint.
Thus, we need to look at our map and find all the spots where the player can place the tower. In our case, the spots that we are looking for are the following:
As we can see, it has a custom shape. Even if it is possible to implement a custom shape, it can be much more convenient to think in terms of rectangles and then to split our shape into rectangles. Of course, this can be done in more than one way; however, using fewer rectangles to cover the entire area is better. On the other hand, by using more rectangles...