SFML community forums

Help => Graphics => Topic started by: skryex on October 26, 2022, 04:08:14 pm

Title: Render Overlap with TileLayer from tmxlite
Post by: skryex on October 26, 2022, 04:08:14 pm
Hello,
I am using tmxlite to parse my .tmx file using its MapLayer class from SFMLOrthogonalLayer.hpp. I am trying to implement basic overlap from the y position, i.e. the player walks in front of a tree then I draw the player first, and if they walk behind the tree, I draw the tree first.

I am having difficulties implementing this. In my case, all my trees are on a single TileLayer, Which when drawn draws chunks themselves made of sf::Vertex, but in the end the TileLayer is still rendered at once.

Is there an easy way to somehow get the layer to draw tile by tile ? This way I'd be able to do a check on the tile's y coordinate before drawing it or not. One other solution is to convert all the objects that the player interacts with in, well, objects in a ObjectGroup layer.
Title: Re: Render Overlap with TileLayer from tmxlite
Post by: fallahn on October 28, 2022, 11:10:27 pm
Tmxlite itself doesn't have any particular utilities for this sort of thing - it's designed purely as a way to convert tmx map data into C++ data structures. However some time ago I did write a post about z-ordering with Tiled which might help you set up your maps:
https://trederia.blogspot.com/2014/08/z-ordering-of-sprites-in-tiled-maps.html

There's also this post by Elias Daler which is useful:
https://eliasdaler.wordpress.com/2013/11/20/z-order-in-top-down-2d-games/

And, if you can, check out Titan Souls (https://store.steampowered.com/app/297130/Titan_Souls/) on Steam. The game includes all the tmx map files in its assets directory which can be very enlightening. (No affiliation, I just like the game ;) )