API Reference#
For as simple as the tutorials make ppb
look there’s a lot of power under
the hood. This section will cover the raw what of the ppb API. To find out why
decisions are made, see the Discussion section.
A python game framework.
PursuedPyBear is object oriented and event driven. Practically, this means that
most of your code will be organized into classes. Game objects in
ppb
are Sprite
instances, which get contained in
Scenes
. In turn, the GameEngine
contains the scenes and Systems
.
Events
are defined as simple classes and event handlers
are based on their names.
The classes, modules, and methods exported directly are the most used parts of the library and intended to be used by users at all levels (barring make_engine). Advanced features tend to be in their own modules and subpackages.
Exports:
- ppb.run(setup: ~typing.Callable[[~ppb.scenes.Scene], None] = None, *, log_level=30, starting_scene=<class 'ppb.scenes.Scene'>, title='PursuedPyBear', **engine_opts)[source]#
Run a game.
This is the default entry point for ppb games.
Sample usage:
import ppb def setup(scene): scene.add(ppb.Sprite()) ppb.run(setup)
Alternatively:
import ppb class Game(ppb.Scene): def __init__(self, **kwargs): super().__init__(**kwargs) self.add(ppb.Sprite()) ppb.run(starting_scene=Game)
See the Getting Started guide for a more complete guide to building games.
All parameters are optional.
- Parameters:
setup (Callable[[Scene], None]) – Called with the first scene to allow initialization of your game.
log_level – The logging level from
logging()
to send to the console.starting_scene (type) – A scene class to use. Defaults to
Scene
title (str) – The title of the rendered window.
engine_opts – Additional keyword arguments passed to the
GameEngine
.
- ppb.make_engine(setup: ~typing.Callable[[~ppb.scenes.Scene], None] = None, *, starting_scene=<class 'ppb.scenes.Scene'>, title='PursedPyBear', **engine_opts)[source]#
Setup a
GameEngine
.This function exists for third party modules to use the same code paths as
run()
for setting up their engine. If you want to instantiate your own engine, you can do so directly using theconstructor
.- Parameters:
setup (Callable[[Scene], None]) – Called with the first scene to allow initialization of your game.
starting_scene (type) – A scene class to use. Defaults to
Scene
title (str) – The title of the rendered window.
engine_opts – Additional keyword arguments passed to the
GameEngine
- Returns:
A GameEngine instance.