1
General discussions / Re: Resources and discussion about good game engine design and clean code
« on: February 21, 2017, 04:57:33 am »
Much like Ironbell I think game and engine should be separate, but I think go one step further split up your code into two main aspects, each having very modular and as much as possible separate libraries:
Then all your game really is, is linking and initialising the systems, libraries and modules you want to use and then providing the data for them.
The next step is then have a clean API. By clean I mean only have one method for doing something. Look at this as an example:
What you want to think about is, will the end user be confused by this many options and what is my actual use case for this code? Does an entity need a world or vice versa? Who owns the entity? Can we simplify to one option?
From there it's the basic:
- Game Engine
- Rendering
- Physics
- Networking
- File
- Logging
- Command Line Parsing Library
- Reflection
- Serialisation\Deserialisation
- Entity System
- Scene Management
- Input
- Audio
- UI
- Pathfinding
- Framework
- Inventory\Item\Equipment System
- Statistic System (Health, Mana, Strength etc)
- Quest System
- Ability System
- Weather System
- Player Controllers
- AI Controllers
Then all your game really is, is linking and initialising the systems, libraries and modules you want to use and then providing the data for them.
The next step is then have a clean API. By clean I mean only have one method for doing something. Look at this as an example:
Entity* entity = new Entity(...);
world->AddEntity(entity);
// And
Entity* world->CreateEntity(...);
// And
Entity* entity = new Entity(world, ...);
world->AddEntity(entity);
// And
Entity* world->CreateEntity(...);
// And
Entity* entity = new Entity(world, ...);
What you want to think about is, will the end user be confused by this many options and what is my actual use case for this code? Does an entity need a world or vice versa? Who owns the entity? Can we simplify to one option?
From there it's the basic:
- Const correctness
- Smart Pointer \ Owner semantics
- Single Responsibility Principle