August 26, 2015
In the real world, when one person is standing in front of another, you see the front person and not so much of the one behind. In a game world, it is a little bit difficult to ensure that interacting objects display to show accurately who is "in front." Let me show you what I am talking about.
If we choose to not think about layering, we may easily end up drawing sprites in random order, with the effect that one sprite may look like it is walking on another sprite's head.
What we really want though is to put sprites behind each other in a way that is logical. Basically, this is done by comparing the sprites' y-coordinates to determine which sprite is further forward on the screen. The sprites are all then stored in a single array in sorted order and drawn in order from back to front. The result is exactly what we hoped for.
Great! We solved the problem! ... or did we? Well, we did until we get to a situation like this one:
Goo--wait a minute...
So the problem is that the same ordering based on y-coordinates is used for both frames 2 and 4 causing either both ladies to be over or under the tent. Because of the linearity in drawing order for sprites, it becomes an O(n^2) problem to sort these properly. The only good solution is to do something like split the tent into two parts with separate coordinate bases:
The blue dots indicate the coordinate bases for each half.
Voila! Problem solved, right? Well, technically we have reached a solution, but practically we are far from a good solution. As a team, we don't want to have to place two halves of a tent every time we place a diagonal tent and then have to align the halves. On the other hand, getting the engine and/or editor to handle this for us is no walk in the park.
Right now, we plan to do as our predecessors (e.g. Zelda: A Link to the Past) appear to have done and just avoid the problem--only use rectangular sprites. I'm not making any promises about the guest appearance of a diagonal sprite.