Entities
We will assume you are familiar with the pygame-ce library fundamentals in the following, if not please refer to the pygame-ce docs.
Attributes
Entities the things that will fill your scene, be it players, NPCs, interfaces, or even a whole level.
Each entity has the following attributes :
rect : pygame.FRect
: an object that represents the entity's position and sizeuid : int
: a unique id for every entity createdtags : list[str]
: list of tagsdebug_color: tuple | str
: a color used to outline the entity in the debugging viewparent_scene : Scene | None
: a pointer to the scene where the entity is added, None if the entity isn't added.
Furthermore, there are methods available to use these attributes, such as :
set_position(self, x, y)
add_tags(self, *tags)
- ...
Lifecycle
As soon as an entity is added to a scene via scene.add_world_entity()
or scene.add_hud_entity()
it is managed by that scene, which means do the following in order:
-
The scene will propagate events to the entity
-
The scene will update the entity every frame
-
The scene will draw the entity if it's
Drawable