Search⌘ K

Composing the Player

Explore how to construct a player entity in Rust using the ECS architecture by defining components such as Player tags, Render details, and Position data. Learn to modularize your game entities for better scalability and maintainability.

We'll cover the following...

Rather than coding everything player-related into a single module, the ECS approach describes a player in terms of what components they use. The Player module from the previous lessons reveals some components that meet our needs:

  • A Player component indicates that the player is a Player. Components needn’t contain any fields. An empty component is sometimes called a tag; it serves to flag that property exists.

  • A Render component describing how the adventurer appears on the screen.

  • A Position component indicates where they are on the map. The Point structure from bracket-lib is ideal for this; it contains an ...