[ad_1]
I have been engaged on a customized tile-based map editor for some time now, and all the pieces works as anticipated, or so I assumed till I’ve tried rendering the precise map together with the dynamic objects as properly.
Because it at present works, it is saving knowledge right into a buffer in a format of:
[ground layer]
[on-ground layer] (flowers/rocks)
[wall layer]
[on-wall layer] (home windows/torches/bookshelves)
So mainly there is a complete of 4 layers.
The tiles are rendered from high left nook to backside proper nook within the following order:
[ground layer] -> All tiles
[on-ground layer] -> All tiles
[wall layer] Does an occasion exists on that spot? in case it does the occasion will get rendered first, after which the tile itself.
[on-wall layer] renders usually proper after that.
This method appears completely effective it the sport has a grid-based motion, in addition to if all of the dynamic sprites are the identical dimension just like the tile dimension. Why? Properly, you’d simply stroll anyplace and get lined with a sure tile or be drawn over a sure tile. Alternatively, if any of the dynamic situations has for instance a sprite top which is larger than the precise tile dimension the depth sorting points seem.
Instance:
We have got a pillar which is 16×48 in dimension. The very backside of the pillar has a collider of 16×16 and it could’t be stepped on, however the mid and high half haven’t any colliders. Now if a participant for instance steps on the topmost tile of the pillar all the pieces will get rendered usually. Alternatively if the steps on the mid tile, the “participant’s head” can be rendered over the topmost tile..
I am questioning if there’s an precise answer for depth ordering in a case like this.
[ad_2]