-
Notifications
You must be signed in to change notification settings - Fork 7
Home
Ember was created to combine the best of component/entity based game architecture and DI driven frameworks.
Ember is built on some core design principles that may help to understand the architectural design choices.
- Composition and interfaces are favoured over inheritance
- Modular (Multiple ember games can simultaneously co-exist, No singletons)
- Minimalist (It’s a framework not a game engine)
- Data driven
There are many interpretations of how to implement this kind of architecture, Ember closely follows the concepts descibed in this blog
http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/
Note: this is not traditional OOP it breaks the rules but with good reason.
There are 3 main parts Entities, Components and Systems.
Entities are just a unique key for retrieving components although they have some methods for convenience they are essentially just a key. In Ember you create an entity like this.
var e:IEntity = entityManager.createEntity("bob");
Components are just data they have no methods. Components can be registered with an entity. Together with entities these make up the games data model. You can add a component to an entity like this
e.addComponent(new Spacial2D());
and you can retrieve a compoment from an entity like this
var spacial:Spacial2D = e.getComponent(Spacial2D());
Systems are where all the work is done. Systems can communicate with other systems via events. Systems can also request a list of entities with a specific set of components and act on them. Systems use automated DI to make coding them quick and clean. For example all games would probably have a render system. You can register a system with the game like this.
systemManager.addSystem(ProcessManager);
and a system can retrieve a list of entities with a set of components like this
var renderableEntities:Vector.<IEntity> = entityManager.getEntityFamily(Graphics,Spacial2D);
read more in getting started