I am working with C++ but this problem is mostly language independant.
So, I am at the beginning of creating a small game to get used to SFML. One thing which has always been hard for me is to write my classes such that they are mostly independant and easy to manage.
For example, my first idea to run the game was:
There are scene classes and visual classes, deriving from SceneBase and VisualBase respectively. They always exist in pairs of two and represent things like the title screen, the main menu or the ingame screen.
The scene classes are responsible for handling data, user inputs and general game logic like collision detection.
The visual classes are responsible for managing sprites, texts and drawing those on the window.
Then there is a main loop which keeps running until the game ends. It has two local pointer variables of type SceneBase* and VisualBase* which, obviously, point to the objects of the current scene and visual.
It would look something like this:
while (window is open)
draw visual on window
As I said, the scene controls its own data so I would have to pass that data to the visual somehow. And of course, a VisualTitleScreen object would need a SceneTitleScreen, not just any SceneBase. So the issue with my idea is that I would have to reinterpret_cast the SceneBase pointer. And I have been told: if you have to use reinterpret_cast in your program, you are doing something wrong :)
So, I am not satisfied with this solution and I am looking for another one.
If I made myself not clear or someone is looking for a tl;dr:
I am looking for good ways to manage data, game logic and visuals of different "scenes", meaning things like the title screen, the main menu, a world map or a battle screen.