Member
✔️ HL Verified
🌟 Senior Member
Can you create a class diagram of your program? This usually shows you the problem.
I haven't done that many graphical C++ applications/games from scratch so I can't tell you for sure what to do.
What you could do is pass on pointers of different managers to the appropriate objects.
The following setup is based on the XNA framework and is in my opinion quite nice, but I'm not sure if Harsen's agrees on this one.
Perhaps I'm giving away too much right now, if so, sorry for that. I'm not telling you to do it this way, but it might give you some inspiration.
Snippet;
As you can see every class is responsible for it's own functionality, yet you can get to other managers using the application pointer if needed.
I haven't done that many graphical C++ applications/games from scratch so I can't tell you for sure what to do.
What you could do is pass on pointers of different managers to the appropriate objects.
The following setup is based on the XNA framework and is in my opinion quite nice, but I'm not sure if Harsen's agrees on this one.
Perhaps I'm giving away too much right now, if so, sorry for that. I'm not telling you to do it this way, but it might give you some inspiration.
Snippet;
Code:
class IUpdateable { virtual void update(long gameTime); }
class IDrawable { x, y, width, height, virtual draw(long gameTime) }
class IPrimitve : IDrawable : IUpdateable { int r, g, b; //colors }
claas IScreen : IDrawable, IUpdateable { ScreenManager *screenManager, draw(), update() ... }
class Application { ScreenManager *screenManager, GameManager *gameManager, InputManager *inputManager...}
class ScreenManager : IUpdateable, IDrawable { Application *application, IScreen *parent, Vector<IDrawable*> children ... }
class Circle : IPrimitive { int radius, bool filled, ... }
class GameManager : IUpdateable { Application *application, IGameState *activeGameState, ...}
class GameScreen : IScreen { ... }
- Application
... ze application loop () !
- ScreenManager
- GameScreen
... do something like this->screenManager->getScreenSize() for example
... children.push_back(new Circle());
- GameManager
... do something like this->application->screenManager->createScreen(new GameScreen());
- Input Manager