Home Game Development 2d – Depth sorting issue

2d – Depth sorting issue

0
2d – Depth sorting issue

[ad_1]

I’ve been working on a custom tile-based map editor for a while now, and everything works as expected, or so I thought until I’ve tried rendering the actual map including the dynamic objects as well.

As it currently works, it’s saving data into a buffer in a format of:
[ground layer]
[on-ground layer] (flowers/rocks)
[wall layer]
[on-wall layer] (windows/torches/bookshelves)

So basically there’s a total of 4 layers.
The tiles are rendered from top left corner to bottom right corner in the following order:
[ground layer] -> All tiles
[on-ground layer] -> All tiles
[wall layer] Does an instance exists on that spot? in case it does the instance gets rendered first, and then the tile itself.
[on-wall layer] renders normally right after that.

This system seems perfectly fine it the game has a grid-based movement, as well as if all the dynamic sprites are the same size like the tile size. Why? Well, you’d just walk anywhere and get covered with a certain tile or be drawn over a certain tile. On the other hand, if any of the dynamic instances has let’s say a sprite height which is bigger than the actual tile size the depth sorting issues appear.

Example:
We’ve got a pillar which is 16×48 in size. The very bottom of the pillar has a collider of 16×16 and it can’t be stepped on, but the mid and top part don’t have any colliders. Now if a player for example steps on the topmost tile of the pillar everything gets rendered normally. On the other hand if the steps on the mid tile, the “player’s head” would be rendered over the topmost tile..

Screenshot of tile map sorting problem

I’m wondering if there’s an actual solution for depth ordering in a case like this.

[ad_2]

Previous article Latest Apple TV beta adds search via the remote’s Siri button
Next article The RPS Advent Calendar 2023, December 3rd
Hello there! My name is YoleeTeam, and I am thrilled to welcome you to AmazonianGames.com. As the premier destination for all things related to Amazon Games' universe, we are dedicated to providing you with the most exciting and immersive gaming experiences out there. From captivating visuals to exhilarating gameplay, our website is packed with comprehensive insights, updates, and reviews to keep you ahead of the game. Whether you're a seasoned gamer or new to the scene, I am here to guide you through this virtual frontier. If you have any questions or suggestions, feel free to reach out to me at john@yoleesolutions.com. Embark on your Amazon gaming journey today with AmazonianGames.com and let the adventure begin!