class documentation
Represent the top-level game state and its native render context.
Methods
- set_camera(
camera) - Set the camera context.
- set_camera(
- set_input(
input) - Set the current input value.
- set_input(
- level_add(
level) - Add a level to the game.
- level_add(
- level_remove(
level) - Remove a level from the game.
- level_remove(
- level_switch(
index_or_name) - Switch to a level by index or name.
- level_switch(
- set_name(
name) - Set the game name.
- set_name(
- set_position(
position) - Set the game position.
- set_position(
- set_size(
size) - Set the game world size.
- set_size(
- set_is_active(
is_active) - Set the active flag.
- set_is_active(
- set_foreground_color(
foreground_color) - Set the foreground color.
- set_foreground_color(
- set_background_color(
background_color) - Set the background color.
- set_background_color(
- set_current_level(
level) - Set the current level or None.
- set_current_level(
- level_exists(
name) - Return whether a level name is registered.
- level_exists(
- __del__()
- Release the native game resources.
| Parameters | |
| name | Name of the game. |
| size | Game world size. |
| draw | Drawing context used to render the game. |
| input | Input manager used to handle input. |
| foreground | Foreground color. Defaults to 0xFFFF. |
| background | Background color. Defaults to 0x0000. |
| camera | Camera used to render the game. Defaults to None. |
| start | Callback called when the game starts. Defaults to None. |
| stop | Callback called when the game stops. Defaults to None. |
| Method | __init__ |
Initialize the game. |
| Method | __setattr__ |
Set a game attribute, routing to the matching setter. |
| Instance Variable | background |
Background color. Writable. |
| Instance Variable | camera |
Current camera context. Writable. |
| Instance Variable | current |
Current level. Writable. |
| Instance Variable | draw |
Native drawing context. Read-only. |
| Instance Variable | foreground |
Foreground color. Writable. |
| Instance Variable | input |
Most recent input value. Writable. |
| Instance Variable | input |
Undocumented |
| Instance Variable | is |
Whether the game is active. Writable. |
| Instance Variable | MAX |
Maximum number of tracked levels. |
| Instance Variable | name |
Game name. Writable. |
| Instance Variable | position |
Current game position. Writable. |
| Instance Variable | size |
Game world size. Writable. |
| Method | _update |
Update the game input and entity positions in a thread-safe manner. |
def __init__(self, name:
str, size, draw, input_manager, foreground_color: int = 65535, background_color: int = 0, camera_context=None, start=None, stop=None):
¶
Initialize the game.
| Parameters | |
name:str | Name of the game. |
size:Vector | Size of the game. |
draw:Draw | Draw context used to render the game. |
inputInputManager | Input manager used to handle input. |
foregroundint | Foreground color of the game. Defaults to 0xFFFF. |
backgroundint | Background color of the game. Defaults to 0x0000. |
cameraCamera or None | Camera context used to render the game. Defaults to None. |
start:callable | Function called when the game is started. Defaults to None. |
stop:callable | Function called when the game is stopped. Defaults to None. |