Hi Nexus!
Thank you for the detailed answer. I understood a few things, but not everything I guess.
In your POV, I should always use plain objects, when I can't then unique_ptr, and if I still can't then pointers. References only for methods parameters.
I think I really need to be pointed to a tutorial that shows the mechanics, because it's still confusing.
Say I have these typical (??) game engine classes:
- A Game instance, that manages a bit of everything, the heart of the game in some way
- A few State instances, that represent the different game states (splash screen, menu, in-game, ...)
I'm still unsure how to define the member variables (or methods parameters), regarding RenderWindow, AssetManager, etc.
1) Plain objects, public visibility, in the Game instance, and a static instance() accessor so that we can retrieve the game easily?
2) Do as I were once told: never use public members. Therefore, RenderWindow and AssetManager instances are protected and will be passed by reference to the StateManager, so that it can also pass them by reference to the States
3) Any other solution...
For now, I went with solution 1) in my code, because I fought so much with solution 2) earlier, that I decided to go with the easiest possible solution...
Is there a preferred way to do it? But then, when do the unique_ptr come into play? (I only use them in the AssetManager, thanks to the SFML book advices)
I'm sorry for my question. But C++ is really a pain in my back!
I'm used to Java, Javascript, and PHP, which are way easier to use... No question to ask yourself: in Java everything is a pointer. Piece of cake
In PHP objects are passed by reference and primitive types variables are passed by value. Piece of cake
I really need to dive into a (recent) game engine tutorial. I found the one of GQE, which is interesting but incomplete.
Best regards,