Hello dear forum : )
Using C++, but possible design patterns are probably not limited to the language, therefore no "C++"-tag,
I have a level-class with a vector of vectors (containing entity-game-objects) as structure for my level because the level is predictable; grid-based.
Each game-object owns a graphics-component, containing all required information by my rendered API.
Of course my level-class shall not be in charge to draw entities, therefore I would like to implement a painter-class.
However I'm not sure what would be the good-practice-way to tell my painter-class what to draw.
Additionally, there are also GUI-widgets that needs to be rendered. As they have no grid-based appearance, they just lie within a vector of widgets and show their coordinates.
Simple: Just pass a reference of the 2d-vector to the paint-class. This the easier route and should probably preferred over more complex code.
While this is sufficient for my needs, should a usual painter-class even have the necessity to know the level-format?
Alternative: Letting the painter-class have a vector of pointers to each graphics-component within an entity.
This removes one dependency of knowing the level-structure and leaves the dependency of knowing how the graphics-component works.
Removing the component-dependency: Implementing a wrapper-class containing texture-reference, coordinates and a link to the original graphics-component.
Of course, I would also require a second vector for GUI-widgets.
I thought about using a queue over a vector. But I'm not sure if the painter-class should dequeue/remove an item or if the level-(un)loader-class should trigger a flag to do this.
So thought I will save quite a few iterations if the painter-class does not need to remove elements once done.
Are there better ways to do this? How would you implement a painter-class?
Thanks for taking your time to read through my thread : )!