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
Playercomponent indicates that the player is aPlayer. Components needn’t contain any fields. An empty component is sometimes called a tag; it serves to flag that property exists. -
A
Rendercomponent describing how the adventurer appears on the screen. -
A
Positioncomponent indicates where they are on the map. The Point structure frombracket-libis ideal for this; it contains an ...