I have tried to design a class diagram for my first game. But then I realized that there are some ugly parts.
First, there is reference from
State and from
StateSystem object contains references to
State instances and one of them is always current.
StateSystem calls it's update and render functions. But every instance of
State also has to have a reference back to
StateSystem, so it can change state to another one. I'd like to know how to avoid the circular dependence in this case.
Secondly, I don’t know where to hold reference(s) to the
Input object. Generally, all classes which belong to the UI (green classes) need a reference to the same instance (only existing instance) of
Input due to mouse collision detection.
Input contains stored information about pressed keys, mouse coordinates and so on. Should I store the reference in every object that needs it?
Moreover, what about
TextureManager class? The only thing it does is store
Texture instances via string IDs (and preparing it for OpenGL) and when needed, it returns a texture according to a given ID. Should I consider using, for example, the Builder pattern and let only the "director" object own the texture manager and create concrete textures for objects?