fallahn / tmxlite

lightweight C++14 parser for Tiled tmx files
Other
392 stars 65 forks source link

Anything against making MapLayer::Chunk public? #156

Open ldornbusch opened 4 months ago

ldornbusch commented 4 months ago

I am working now for some time with this library, but recently I stumbled over a small detail which blocks my progress : I am using properties on tiles and objects to mark in my level certain elements like keys, switches, switchable doors, enemies, etc. usually I add properties to these objects to customize the behavior.

I also want to use this principle for moving platforms and other decorations: For example: image Here you see such a platform ("moving_platform") and its parameters(it will swing 40px up an down again). The advantage is that you can easily paint your level and even draw the paths of moving platforms and enemies inside the level editor. But the problem is, that the code for rendering a part of the map is implemented in the Chunk class which is private to MapLayer. From an Software architecture pov I would like to manage the moving platforms outside of the MapLayer, but then I cannot instantiate a Chunk. I cannot derive MapLayer nor Chunk as both are declared final(<--why?). Only possibility I see is to duplicate the code. But we are not using C++ to start to copy+paste methods into new classes, do we?

Would it be fine to make chunk public or the classes not final? Or is there something else I miss?

fallahn commented 4 months ago

I have to admit I haven't used this in a while so I've kind of forgotten how it works πŸ˜…

Just had a quick look at the source though - it seems Chunk is a public struct in the TileLayer class, which also has a public getter for the chunk array. Is your version out of date perhaps? Like I say, I can't really remember how it works, or how it's changed over the years 😳

ldornbusch commented 4 months ago

Thanks for the reply. I was unclear in my request: I was referring to the MapLayer::Chunk inside the SFML example: https://github.com/fallahn/tmxlite/blob/3633ea56e141663937543a1413c5cce913bf9f06/SFMLExample/src/SFMLOrthogonalLayer.hpp#L179 There the Chunk is private and final inside a MapLayer declared final as well. I would like to know the rationale for the final keyword and would ask if I can remove it and make chunk public in a PR to help me with keeping my project better synchronized with upstream. This should not impact any project negatively.

fallahn commented 4 months ago

Oh! I apologise πŸ˜…

The SFML example is meant as just that - an example. It's mostly written by contributors now too. If you have something that you feel is useful and improves upon it (without breaking existing features) then any changes are welcome! 😁 Thanks