I'm trying to learn how to produce quality object-oriented code and have been studying concepts like SOLID. I'm currently working on an entity-component-process system for a small game engine.
Currently, I have it implemented as such:
- There is a
ScreenStackwhich contains a stack of
Processes given entities from the
Processhandles all game logic, so it needs to be able to use
ScreenStackto possibly push and pop screens. It can also create, remove, and change entities, so it needs the
Screen. Basically a
Processneeds to know everything about the game since it affects so much of it, but it feels wrong.
How do I go about implementing this better? It seems like everything has a clear dependency hierarchy until you get to a process, where it gets thrown out the window.
There also seems to be tight coupling when I would want to push a new screen. Say, for example, I have a process in a
MainMenu screen that checks for menu choice. If "New Game" is clicked, I need to push a new screen, which gets created at that moment. I've read that I shouldn't randomly throw in
new which this seems to be doing.