Game Object Model¶
The Game Object Model.
-
class
ppb.gomlib.
Children
[source]¶ A container for game objects.
Supports tagging.
-
add
(child: Hashable, tags: Iterable[Hashable] = ()) → Hashable[source]¶ Add a child.
Parameters: - child – Any Hashable object. The item to be added.
- tags – An iterable of Hashable objects. 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: Hashable = 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. 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: Hashable) → Hashable[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: Hashable, 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()
-
kinds
¶ Shorthand for
Children.kinds()
Deprecated since version 0.10: Use
.children.kinds()
instead.
-
remove
(child: Hashable) → None[source]¶ Shorthand for
Children.remove()
Shorthand for
Children.tags()
Deprecated since version 0.10: Use
.children.tags()
instead.
- Property-based init (