Understanding Terminology

Hands-on Rust — by Herbert Wolverson (51 / 120)

The Pragmatic Programmers
The Pragmatic Programmers
2 min readSep 23, 2021

--

👈 Chapter 6 Compose Dungeon Denizens | TOC | Composing Entities 👉

ECS uses a common set of terms to denote its different parts:

  • An entity can be anything: an adventurer, an orc, or a pair of shoes. The game map is an exception — it’s usually not an entity, but rather a resource entity’s reference to travel. Entities don’t have logic associated with them; they are little more than an identification number.
  • A component describes a property an entity may have. Entities typically have lots of components attached to them, serving as a description — and adding functionality through systems. For example, a goblin might have a Position component describing where it is on the map, a Render component describing how to render it, a MeleeAI component indicating that it attacks with hand-to-hand combat, and a Health component describing how many hit points it has left. A sword might also have a Position component describing its location on the map, and a Render component indicating what it looks like. It would differ from the goblin by having an Item component to indicate that it’s an item. Components don’t have logic associated with them, either.
  • Systems query the entities and components and provide one element of game-play/world simulation. For example, a Render system might draw everything with a Render component and a Position component onto the map. A Melee system might handle hand-to-hand combat. Systems provide the “game logic” that makes your game function. Systems read entity/component data and make changes to them — providing the powerhouse that makes the game function.
  • Resources are shared data available to multiple systems.

This diagram illustrates the relationship between these terms.

images/EntitiesComponentsAndSystems/EntityComponentSystemResources.png

👈 Chapter 6 Compose Dungeon Denizens | TOC | Composing Entities 👉

Hands-on Rust by Herbert Wolverson can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.

Unlisted

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.