Sorting the occlusion
When using top-down views, we will encounter one of the two possibilities: either the "camera" looks straight down at the ground or with a slight angle. The following figure illustrates the two situations:
In the first case, the only situation where an element is hidden by another one is if it's straight above it. It's quite easy to produce this effect; we can simply use a group for each altitude and place the sprites and tile maps in the right group.
For example, let's consider a level that contains a tree and a bridge under which the player can walk, just like in the following figure:
We could organize our game screen like this:
Once this is done, there is not much to worry about. If at some point an NPC (non-player character) or the player moves up or down, we just have to remove them from one group and add them to the other one.
Most modern games, however, use the second type of view, and that's the one we will use for our small game. With this perspective, it's not...