Components store all entity data in a given World. You can think of components as tables with entities as their primary keys. Like database tables, components are defined with a “schema” that specifies the data fields. Each field in a component has a name and a type.
Component objects themselves have a dict-like interface with entities as keys and data records as values. An application will typically interact with components via entity attributes, entity extents or by joining them. For more information see:
See also defining custom components in the tutorial.
General component with a configurable schema
The field schema is defined via keyword args where the arg name is the field name and the value is the type object.
The following types are supported for fields:
Set the component data for an entity, adding it to the component if it is not already a member.
If data is specified, its data for the new entity’s fields are copied from its attributes, making it easy to copy another entity’s data. Keyword arguments are also matched to fields. If both a data attribute and keyword argument are supplied for a single field, the keyword arg is used.
Update the component for the next timestep
Predefined component that stores position and orientation info for entities.
Fields:
Predefined component that stores offset, shear, rotation and scale info for entity shapes.
Fields:
Predefined component that stores velocity, acceleration and rotation info for entities.
Fields:
Predefined component that stores shape vertices for entities
Predefined component that identifies entities to be rendered and provides their depth and color.
while rendering.
field depends on the renderer.
Predefined component that stores collision masks to determine which entities can collide.
Fields:
This is used for broad-phase collision detection.
collision detection. The exact meaning of this value depends on the collision system in use.
can collide with.
with this object.
When considering an entity A for collision with entity B, A’s from_mask is bit ANDed with B’s into_mask. If the result is nonzero (meaning 1 or more bits is set the same for each) then the collision test is made. Otherwise, the pair cannot collide.
The default value for both of these masks is 0xffffffff, which means that all entities will collide with each other by default.