Introduction to Entity Component System

A guide to the basic concepts.

Dean James
5 min readSep 20, 2020
Photo by Safar Safarov on Unsplash

What is Entity Component System?

Entity Component System is a software pattern commonly employed in game development.

It is designed to take full advantage of a computer’s hardware to maximize performance, whilst also providing the programmer with a structured, modular environment.

The three parts to ECS

The pattern comprises three parts: entities, components, and systems.

An Example

To better explain the concepts involved in the ECS pattern, consider a 2D platformer with the following objects:

  • A player controlled by a mouse and keyboard.
  • A static tree.
  • Two zombies controlled by AI.

What Would this Look Like in OOP?

In object oriented programming, data and functionality are kept tightly encapsulated within classes, promoting inheritance like in the following diagram:

--

--