Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Entity Component System Frameworks - Notes and Research

"Entity Component System" (ECS) frameworks are a data-driven approach to managing and processing objects in a game world. Rather than using a rigid, OOP-style class structure with inheritance to represent objects, we say that each object is an "entity" - nothing more than an ID number and a bag of "components" which contain data about the object. We then define "systems" which act on entities with a matching set of components.

Example

The ubiquitous example of ECS would be implementing a "MovementSystem" which handles movement for game objects. In pseudocode we might say:

System movementSystem = new System();
movementSystem.match(PositionComponent, VelocityComponent);
movementSystem.onTick(function(Entity e) {
	e.getComponent(PositionComponent.position).add(e.getComponent(VelocityComponent.velocity));
});

Entity player = new Entity();
player.attachComponent(new PositionComponent(4, 6));
player.attachComponent(new VelocityComponent(1, 1));

Entity wall = new Entity();
wall.attachComponent(new PositionComponent(10, 10));

world.addEntity(player);
world.addEntity(wall);
world.addSystem(movementSystem);

world.tick();
// now player has position (5, 7), wall has not moved

We define a movement system which matches all entities which have both a PositionComponent and a VelocityComponent. We also define a player entity and a wall entity; the player has both components and so is matched by the movement system while the wall lacks a velocity (as you might expect!) and so does not match.

We have some over-arching "world" which handles the internal mechanics of the framework, and when we call "tick" each system is run in turn. We see that the player's position is increase by its velocity and the wall's position is unchanged as expected.

Other Documents

"Game Engine Architecure", Jason Gregory

Full citation: Jason Gregory, "Game Engine Architecure", Natick, MA. A K Peters, 2009 Pages 728 - 733

About

Research and descriptions of ECS implementations

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors