Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Render Overlap with TileLayer from tmxlite  (Read 1184 times)

0 Members and 1 Guest are viewing this topic.

skryex

  • Newbie
  • *
  • Posts: 1
    • View Profile
Render Overlap with TileLayer from tmxlite
« 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.
« Last Edit: October 26, 2022, 04:50:37 pm by skryex »

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: Render Overlap with TileLayer from tmxlite
« Reply #1 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 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 ;) )