superLED wrote:I would make a static class for the player.
That way, you can include "player.h" and use "Player::getX();"
And for the enemies, make a static class that holds all the enemies, so you can do like this: "Enemies::getEnemy(3)->kill();"
And the same for the tileManager. "if(TileManager::getTile(43)->isSolid()) { };"
A little while ago, I had to pass &player to every function in another class to access him. enemy.checkCollision(&player)... and so forth.
The same with my Input class and all that stuff.
When I have a class that I will be using all over the place, I make it either a static class or make a static class that holds every instance of that object.
What you are doing is basically no different than a singleton. I wouldn't recommend that.
The question that codeblue9955 is asking is
one hell of a loaded question. This is essentially the biggest question in engine development--or any other form of object-oriented software development. It encompasses the entire field of design patterns. It
is object-oriented development.
There is no single answer to your question. There is no single mechanism that that you can employ to communicate between every class that will always be the best case (unless you go the inexperienced route and either make everything static or a singleton). The preferred design patterns are different for different areas of your software architecture.
I remember asking the exact same question when I began my own development. I originally started with C, where that shit didn't matter. Then I went to C++, and I began abusing singletons/global statics like every other newbie out there... Then I began learning the art of understanding which scenarios warranted which design patterns.
I wish that I could offer you a less cryptic post than this one, but the truth is that the "real" answer to this question would require me writing an entire engine for you. Different classes communicate differently. The best piece of advice that I can give is to read up on design patterns and look at other peoples' software architecture.