Game Object Model¶
The Game Object Model.
-
class
ppb.gomlib.
Children
[source]¶ A container for game objects.
Supports tagging.
-
add
(child: ppb.gomlib.GameObject, tags: Iterable[Hashable] = ()) → ppb.gomlib.GameObject[source]¶ Add a child.
Parameters: - child – Any Game Object. The item to be added.
- tags – An iterable of Hashable objects. (Probably strings.) Values that can be used to retrieve a group containing the child.
Examples:
children.add(MyObject()) children.add(MyObject(), tags=("red", "blue")
-
get
(*, kind: Type[CT_co] = None, tag: Optional[ppb.gomlib.GameObject] = None, **_) → Iterator[T_co][source]¶ Iterate over the objects by kind or tag.
Parameters: - kind – Any type. Pass to get a subset of contained items with the given type.
- tag – Any Hashable object. (Probably strings.) Pass to get a subset of contained items with the given tag.
Pass both kind and tag to get objects that are both that type and that tag.
Examples:
children.get(type=MyObject) children.get(tag="red") children.get(type=MyObject, tag="red")
-
remove
(child: ppb.gomlib.GameObject) → ppb.gomlib.GameObject[source]¶ Remove the given object from the container.
Parameters: child – A hashable contained by container. Example:
container.remove(myObject)
Generates all of the tags currently in the collections
-
-
class
ppb.gomlib.
GameObject
(**props)[source]¶ A generic parent class for game objects. Handles:
- Property-based init (
Sprite(position=pos, image=img)
) - Children management
-
add
(child: ppb.gomlib.GameObject, tags: Iterable[T_co] = ()) → None[source]¶ Shorthand for
Children.add()
-
children
= None¶ The children of this object
-
get
(*, kind: Type[CT_co] = None, tag: Hashable = None, **kwargs) → Iterator[T_co][source]¶ Shorthand for
Children.get()
-
remove
(child: ppb.gomlib.GameObject) → ppb.gomlib.GameObject[source]¶ Shorthand for
Children.remove()
- Property-based init (