9

enter image description here enter image description here enter image description here enter image description here

Above are four images of a character walking along the ground from the bottom right towards the upper left. You can see that the drawing order isn't correct in the third panel.

There doesn't seem to be a "correct order" here. For example if instead of a small guy we had a sprite of a looooong cat going through the door, then no matter if you draw the door first or the cat first, it would be wrong.

enter image description here enter image description here

How do other game engines handle this? Some hack to prevent this situation from happening? Draw a z-buffer by hand? Some other option that didn't occur to me?

Bemmu
  • 17,849
  • 16
  • 76
  • 93
  • Maybe defining a set of "layers" for the object (or having separate objects altogether), with the first layer being drawn below the second, etc.? I dunno for sure, but that would be my naive approach. I'd set a bounty on this if I actually had a use for knowing this sort of stuff. – Blender Mar 10 '11 at 04:59
  • Thanks blender. Actually I do have layers in my engine, but the tiles being in different layers doesn't affect the drawing order in comparison with the sprites. – Bemmu Mar 10 '11 at 05:38
  • I was meaning layers for each individual sprite. I've got to work on my terminology... – Blender Mar 10 '11 at 05:42

2 Answers2

5

The trick is simply to split the tile into pieces. Draw the right half of the arch, then the character, and then the left half.

supercat
  • 77,689
  • 9
  • 166
  • 211
  • Hmm so a tile isn't just an image drawn in the center of a tile, but can actually be a collection of images at offsets. – Bemmu Mar 10 '11 at 05:24
  • 1
    Simple answer but got me thinking. If I add the feature to have tile groups (a useful feature anyway), then I could create a tile group that has those two parts. – Bemmu Mar 10 '11 at 09:41
0

An alternative to splitting the tile is to just render everything with z-values and a z-buffer like a proper 3d app would. If you generate your graphics in a 3D package you can probably generate the relative z values at the same time.

Kylotan
  • 18,290
  • 7
  • 46
  • 74