All About Scenes

Scenes are the terrain where sprites act. Each game has multiple scenes and may transition at any time.

class ppb.BaseScene(*, set_up: Callable = None, pixel_ratio: numbers.Number = 64, **kwargs)[source]
background_color = (0, 0, 100)

An RGB triple of the background, eg (0, 127, 255)


An object representing the view of the scene that’s rendered

add(game_object: Hashable, tags: Iterable[T_co] = ()) → None[source]

Add a game_object to the scene.

game_object: Any GameObject object. The item to be added. tags: An iterable of Hashable objects. Values that can be used to

retrieve a group containing the game_object.


scene.add(MyGameObject(), tags=(“red”, “blue”)

get(*, kind: Type[CT_co] = None, tag: Hashable = None, **kwargs) → Iterator[T_co][source]

Get an iterator of GameObjects by kind or tag.

kind: Any type. Pass to get a subset of contained GameObjects with the
given type.
tag: Any Hashable object. Pass to get a subset of contained GameObjects
with the given tag.

Pass both kind and tag to get objects that are both that type and that tag.




scene.get(type=MyGameObject, tag=”red”)

remove(game_object: Hashable) → None[source]

Remove the given object from the scene.

game_object: A game object.