In the game I’m currently working on, it appears that I’m slowly drifting towards a design that’s a close resemblance of the Model-View-Controller (MVC) pattern, despite originally rejecting the idea because I believed it would require my game world to expose too much of its internal data just so the view could keep track of things.
Because I originally believed to be building a very simple game with very simple logic, I chose a design that would create a nice, non-fractured interface to the world so I would have an easier time building the AI and player controls on top of it:
In this design, everything could access everything else – a monolithic world component where the public interface was well encapsulated, but that allowed the implementation to take the most direct path possible.
"Everything could access everything else" doesn’t mean my
objects directly modified each other’s state, but it meant, for example, that
a building had a reference to the island it was placed on and that it could
call an internal method in the Island
class to inform it when
the building was destroyed or moved.
A full design, in contrast, would give the buildings an interface through which they determined properties about the ground (is it too rough? underwater?) and some events so its owner would know when the building was destroyed.
If I had only taken game logic into account, this all would have worked out very well. But there were some things that added a lot of complexity…
Read More