Hello,
I have built games in the past in unity and XNA, android SDK etc. but it’s always been quite specific, when building a small Game Engine or more accurately a sub-set of code that is reusable across projects the tendency to structure the project falls towards composition of objects that are more "generic" than toward inheritance-based models.
For the Engine specific sub-systems, we have components such as a MeshInstance/Renderer that contains a Handle to a Mesh in a MeshLibary and a handle to a Material from the material library which in turn hold PSO data etc. We can also have Components such as SoundSorce, which are managed by an AudioSystem and contains the data to specify what sound, at what volume etc.
These systems can be Set up and shut down from within the Engine/Game class such as:
void Engine::Run()
{
if (Initialize())
{
//Main loop call the systems
//Dispatch Events
}
ShutDown();
}
void Engine::Initialize()
{
//Init all sub-systems
FileSystem.Init();
RenderSystem.Init();
PhysicsSystem.Init();
AudioSystem.Init();
WorldManager.Init(); //Creats Entities
}
void Engine::ShutDown()
{
//shutdown all sub-systems
WorldManager.ShutDown();
AudioSystem.ShutDown();
PhysicsSystem.ShutDown();
RenderSystem.ShutDown();
FileSystem.ShutDown();
}
But where does logic go? in smaller games like XNA or SFML you generally create some managers, let’s take the example of darkest dungeon.
They have various managers like:
- Darkest Dungeon Manager
- Campaign Selection Manager
- Estate manager
- Party formation manager
- Town manager
- etc..
All the logic and systems to run the game are based within the managers, and objects contain scripts of data that are fed thorough the systems.
In a small reusable code base how would you separate the logic from the engine, should like the smaller games all the managers just be shoved into the Engine Class even though that goes against a reusable data-driven framework? Should they just be stuck in a GameLogic system that's is initialized in the Engine Initialism function. And how do people tend to connect data scripts to the other various engine systems without causing too much game specific coupling. For example, you can use an Event System, but firing and event such as DAMAGED_BY_ZOMBIE and having the internal engine respond to that seems to break the separation from the low-high level of the engine system.
Would be great to here some opinions from the community on this subject as it is quite a vital and potentially problem prone aspect of engine/game development.
Thanks.