🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Questions about game design patterns - C++

Started by
1 comment, last by Tom Sloper 3 years, 6 months ago

I am trying to solve a problem I always run into when developing engines. I am writing an iPhone game. I have a bunch of classes (EnemyManager, Weapon Manager, Player Manager). These are all game objects in my scene. As I put more logic into the game, these classes need access to eachother's data (i.e. the weapon manager which shoots a bullet needs to have access to projectiles in the weapon manager and the enemies location in the enemy manager). My solution was to include class object pointers. The weapon manager includes a pointer to the enemy manager class object in the scene. This works quite well but it seems a bit messy and after a while, the number of forward declarations start to show. Furthermore, I start to get weird errors of redefinition and such. Obviously, this design patten cannot continue but I need to find a way for the various classes to talk to eachother. This pattern is okay for smaller projects but looks like it will be unsustainable in the long run. I also want to avoid global objects (bad practices) - which in my case would solve the problem as well.https://xender.vip/

Another idea I had was to simply use the managers as holders of data and then in the main scene I could write the logic with the interaction between the classes. But I run the risk of seriously bloating the main game scene with functions. Any advice is greatly appreciated.https://nox.tips/

Advertisement

milestone85 said:
Any advice is greatly appreciated.

Okay. Don't ask programming questions in a Game Design forum. Since you didn't ask about game design, your question has been moved to a programming forum.

Sorry, that was snarky. It's just that everybody is always posting everything in the Game Design forum.

-- Tom Sloper -- sloperama.com

This topic is closed to new replies.

Advertisement