Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anything against making MapLayer::Chunk public? #156

Open
ldornbusch opened this issue May 4, 2024 · 3 comments
Open

Anything against making MapLayer::Chunk public? #156

ldornbusch opened this issue May 4, 2024 · 3 comments

Comments

@ldornbusch
Copy link
Contributor

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
Copy link
Owner

fallahn commented May 4, 2024

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
Copy link
Contributor Author

ldornbusch commented May 6, 2024

Thanks for the reply.
I was unclear in my request: I was referring to the MapLayer::Chunk inside the SFML example:

class Chunk final : public sf::Transformable, public sf::Drawable

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
Copy link
Owner

fallahn commented May 6, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants