Hello!
I am creating an isometric RPG with C++ and SFML. Maps are created in Tiled and loaded using JsonCPP. I am having difficulties sorting the player with bigger sprites.
I have a big tileset with textures of multiple sizes. In Tiled the entire tileset is cut into 1x1 tile pieces, which means a bigger texture like a tree (2x2 up to 2x4 tiles) is drawn as multiple sprites. Which creates problems sorting with the player (as you can see in the attached picture). What I am doing now is setting a priority to each sprite corresponding to the cartesian Y coordinate, and sorting all the sprites before drawing them. The green dots are the y coordinates I use for sorting. Middle bottom of sprites, and between the feet of the player.
I can see a couple solutions to this, all involving drawing larger textures as one sprite.
Adding size of texture as a custom property to tiled. And just placing one of the tree tiles and having the code draw the whole texture. But this will make map creation difficult as it will not look the same in game, I could place the whole tree and setting all tiles except one as not visible.
Split the textures by size into different tilesets. Will this impact performance? How would I know which tile corresponds to which tile set? Preferably dynamic, so I don’t need to change the code when adding another tileset.
Are there better solutions that I have overlooked? Any suggestions be welcome!
Thanks,
Sadbus
↧