class documentation

Represent the top-level game state and its native render context.

Methods

  • set_camera(camera)
    Set the camera context.
  • set_input(input)
    Set the current input value.
  • level_add(level)
    Add a level to the game.
  • level_remove(level)
    Remove a level from the game.
  • level_switch(index_or_name)
    Switch to a level by index or name.
  • set_name(name)
    Set the game name.
  • set_position(position)
    Set the game position.
  • set_size(size)
    Set the game world size.
  • set_is_active(is_active)
    Set the active flag.
  • set_foreground_color(foreground_color)
    Set the foreground color.
  • set_background_color(background_color)
    Set the background color.
  • set_current_level(level)
    Set the current level or None.
  • level_exists(name)
    Return whether a level name is registered.
  • __del__()
    Release the native game resources.
Parameters
nameName of the game.
sizeGame world size.
drawDrawing context used to render the game.
input_managerInput manager used to handle input.
foreground_colorForeground color. Defaults to 0xFFFF.
background_colorBackground color. Defaults to 0x0000.
camera_contextCamera used to render the game. Defaults to None.
startCallback called when the game starts. Defaults to None.
stopCallback 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_color Background color. Writable.
Instance Variable camera Current camera context. Writable.
Instance Variable current_level Current level. Writable.
Instance Variable draw Native drawing context. Read-only.
Instance Variable foreground_color Foreground color. Writable.
Instance Variable input Most recent input value. Writable.
Instance Variable input_manager Undocumented
Instance Variable is_active Whether the game is active. Writable.
Instance Variable MAX_LEVELS 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:strName of the game.
size:VectorSize of the game.
draw:DrawDraw context used to render the game.
input_manager:InputManagerInput manager used to handle input.
foreground_color:intForeground color of the game. Defaults to 0xFFFF.
background_color:intBackground color of the game. Defaults to 0x0000.
camera_context:Camera or NoneCamera context used to render the game. Defaults to None.
start:callableFunction called when the game is started. Defaults to None.
stop:callableFunction called when the game is stopped. Defaults to None.
def __setattr__(self, name, value):

Set a game attribute, routing to the matching setter.

Parameters
name:strAttribute name to set.
value:objectNew value for the attribute.
background_color: int =

Background color. Writable.

camera: Camera or None =

Current camera context. Writable.

current_level: Level or None =

Current level. Writable.

draw: Draw =

Native drawing context. Read-only.

foreground_color: int =

Foreground color. Writable.

input: int =

Most recent input value. Writable.

input_manager: InputManager =

Undocumented

is_active: bool =

Whether the game is active. Writable.

MAX_LEVELS: int =

Maximum number of tracked levels.

name: str =

Game name. Writable.

position: Vector =

Current game position. Writable.

size: Vector =

Game world size. Writable.

def _update(self):

Update the game input and entity positions in a thread-safe manner.