Skip to content

Handler

Event

Event(engine: Engine)

Base event implementation for wame plugins.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

CancellableEvent

CancellableEvent(engine: Engine)

Bases: Event

Base cancellable event implementation for wame plugins.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

cancel

cancel() -> None

Cancel this event from being further handled.

LifetimeEvent

LifetimeEvent(engine: Engine)

Bases: Event

Base lifetime event implementation for wame plugins.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

LoadEvent

LoadEvent(engine: Engine)

Bases: LifetimeEvent

Dispatched when the engine flags your plugin to load/start.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

UnloadEvent

UnloadEvent(engine: Engine)

Bases: LifetimeEvent

Dispatched when the engine flags your plugin to unload/stop.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

SceneEvent

SceneEvent(engine: Engine)

Bases: Event

Base scene event implementation for wame plugins.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

IntVector2

IntVector2(x: int, y: int)

Bases: BaseVector2

2D Integer Vector Array.

Create a new 2D, int-based vector array.

PARAMETER DESCRIPTION
x

Coordinate on the X-axis.

TYPE: int

y

Coordinate on the Y-axis.

TYPE: int

x property writable

x: int

Coordinate on the X-axis.

y property writable

y: int

Coordinate on the Y-axis.

magnitude

magnitude() -> float

Calculate the magnitude of this vector.

RETURNS DESCRIPTION
float

The magnitude of this vector.

copy

copy() -> IntVector2

Copy this vector into another instance of the same vector.

RETURNS DESCRIPTION
IntVector2

This vector as another instance.

dot

dot(other: IntVector2) -> float

Calculate the dot product of this vector with another.

PARAMETER DESCRIPTION
other

The other vector to calculate the dot product with.

TYPE: IntVector2

RETURNS DESCRIPTION
float

The dot product of these two vectors.

from_iterable classmethod

from_iterable(
    iterable: Union[
        IntVector2,
        np.ndarray[np.int32],
        tuple[int, int],
        list[int],
    ],
) -> IntVector2

Create a new 2D, int-based vector array from an iterable with 2 int values.

PARAMETER DESCRIPTION
iterable

The iterable with 2 int values.

TYPE: IntVector2 | numpy.ndarray[numpy.int32] | tuple[int, int] | list[int]

RETURNS DESCRIPTION
IntVector2

The new 2D, int-based vector array.

RAISES DESCRIPTION
ValueError

If the provided iterable contains more or less than 2 values

normalize

normalize() -> FloatVector2

Normalize this vector.

RETURNS DESCRIPTION
FloatVector2

The normalized vector.

RAISES DESCRIPTION
ZeroDivisionError

If the magnitude of this vector is 0

to_numpy

to_numpy(copy: bool = True) -> NDArray[np.int32]

Return this vector as an instance of a NumPy array.

PARAMETER DESCRIPTION
copy

If this method should return a copy of the internal NumPy array or the array itself

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
numpy.ndarray[numpy.int32]

This vector as an instance of a NumPy array.

Warning

If you return the array itself, any changes to that array will change this vector object.

to_tuple

to_tuple() -> tuple[int, int]

Return this vector as a tuple.

RETURNS DESCRIPTION
tuple[int, int]

This vector as a tuple.

JoystickEvent

JoystickEvent(engine: Engine)

Bases: SceneEvent, CancellableEvent

Base joystick event implementation.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

joystick property

joystick: int

The joystick that this event is associated with.

cancel

cancel() -> None

Cancel this event from being further handled.

JoystickAxisMotionEvent

JoystickAxisMotionEvent(engine: Engine)

Bases: JoystickEvent

Dispatched when the scene recognizes movement in a joystick axis.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

joystick property

joystick: int

The joystick that this event is associated with.

axis property

axis: int

The axis of motion in which the joystick moved.

position property

position: float

The new position of the joystick that moved.

cancel

cancel() -> None

Cancel this event from being further handled.

JoystickButtonDownEvent

JoystickButtonDownEvent(engine: Engine)

Bases: JoystickEvent

Dispatched when the scene recognizes that a button has been pressed on a joystick.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

joystick property

joystick: int

The joystick that this event is associated with.

button property

button: int

The button that was pressed.

cancel

cancel() -> None

Cancel this event from being further handled.

JoystickButtonUpEvent

JoystickButtonUpEvent(engine: Engine)

Bases: JoystickEvent

Dispatched when the scene recognizes that a button has been released on a joystick.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

joystick property

joystick: int

The joystick that this event is associated with.

button property

button: int

The button that was released.

cancel

cancel() -> None

Cancel this event from being further handled.

JoystickDeviceAddedEvent

JoystickDeviceAddedEvent(engine: Engine)

Bases: JoystickEvent

Dispatched when the scene recognizes that a joystick device has been added to the system.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

joystick property

joystick: int

The joystick that this event is associated with.

cancel

cancel() -> None

Cancel this event from being further handled.

JoystickDeviceRemovedEvent

JoystickDeviceRemovedEvent(engine: Engine)

Bases: JoystickEvent

Dispatched when the scene recognizes that a joystick device has been removed from the system.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

joystick property

joystick: int

The joystick that this event is associated with.

cancel

cancel() -> None

Cancel this event from being further handled.

JoystickHatMotionEvent

JoystickHatMotionEvent(engine: Engine)

Bases: JoystickEvent

Dispatched when the scene recognizes that the hat of a joystick has moved.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

joystick property

joystick: int

The joystick that this event is associated with.

hat property

hat: int

The ID of the hat that moved.

position property

position: IntVector2

The new position of the hat that moved.

cancel

cancel() -> None

Cancel this event from being further handled.

KeyEvent

KeyEvent(engine: Engine)

Bases: SceneEvent, CancellableEvent

Base key event implementation.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

key property

key: int

The key that this event relates to.

mods property

mods: int

The bitwise-combined keycodes of all modification keys pressed at the time of this event.

cancel

cancel() -> None

Cancel this event from being further handled.

KeyPressedEvent

KeyPressedEvent(engine: Engine)

Bases: KeyEvent

Dispatched when the scene recognizes that a key has been pressed.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

key property

key: int

The key that this event relates to.

mods property

mods: int

The bitwise-combined keycodes of all modification keys pressed at the time of this event.

cancel

cancel() -> None

Cancel this event from being further handled.

KeyPressingEvent

KeyPressingEvent(engine: Engine)

Bases: KeyEvent

Dispatched when the scene recognizes that a key is currently being pressed.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

key property

key: int

The key that this event relates to.

mods property

mods: int

The bitwise-combined keycodes of all modification keys pressed at the time of this event.

cancel

cancel() -> None

Cancel this event from being further handled.

KeyReleasedEvent

KeyReleasedEvent(engine: Engine)

Bases: KeyEvent

Dispatched when the scene recognizes that a key has been released.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

key property

key: int

The key that this event relates to.

mods property

mods: int

The bitwise-combined keycodes of all modification keys pressed at the time of this event.

cancel

cancel() -> None

Cancel this event from being further handled.

MouseEvent

MouseEvent(engine: Engine)

Bases: SceneEvent, CancellableEvent

Base mouse event implementation.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

cancel

cancel() -> None

Cancel this event from being further handled.

MouseMoveEvent

MouseMoveEvent(engine: Engine)

Bases: MouseEvent

Dispatched when the scene recognizes that the mouse has moved.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

relative property

relative: IntVector2

The amount of pixels the mouse has moved.

cancel

cancel() -> None

Cancel this event from being further handled.

MousePressedEvent

MousePressedEvent(engine: Engine)

Bases: MouseEvent

Dispatched when the scene recognizes that a button on the mouse has been pressed.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

button property

button: int

The ID of the button pressed.

cancel

cancel() -> None

Cancel this event from being further handled.

MouseReleasedEvent

MouseReleasedEvent(engine: Engine)

Bases: MouseEvent

Dispatched when the scene recognizes that a button on the mouse has been released.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

button property

button: int

The ID of the button released.

cancel

cancel() -> None

Cancel this event from being further handled.

MouseWheelScrollEvent

MouseWheelScrollEvent(engine: Engine)

Bases: MouseEvent

Dispatched when the scene recognizes that the scroll wheel on the mouse has moved.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

amount property

amount: int

The amount the scroll wheel has moved - Positive if up, negative if down.

cancel

cancel() -> None

Cancel this event from being further handled.

CleanupEvent

CleanupEvent(engine: Engine)

Bases: SceneEvent

Dispatched when the scene is about to clean up.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

FirstEvent

FirstEvent(engine: Engine)

Bases: SceneEvent

Dispatched when the scene is about to begin the game loop.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

FixedUpdateEvent

FixedUpdateEvent(engine: Engine)

Bases: SceneEvent

Dispatched when the scene is about to run the fixed update cycle.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

InitEvent

InitEvent(engine: Engine)

Bases: SceneEvent

Dispatched when the scene is about to run the developer-defined initializer.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

args property

args: Any

The arguments associated with this scene's loading.

kwargs property

kwargs: dict[str, Any]

The keyword-arguments associated with this scene's loading.

UserEvent

UserEvent(engine: Engine)

Bases: SceneEvent, CancellableEvent

Dispatched when the scene recognizes that a custom, developer-defined event has been fired.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

is_cancelled property

is_cancelled: bool

Check if this event has already been cancelled.

scene property

scene: Scene

The active scene that dispatched this event.

event property

event: PygameEvent

The custom, developer-defined event fired by Pygame.

cancel

cancel() -> None

Cancel this event from being further handled.

RenderEvent

RenderEvent(engine: Engine)

Bases: SceneEvent

Dispatched when the engine flags your plugin to render.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

UpdateEvent

UpdateEvent(engine: Engine)

Bases: SceneEvent

Dispatched when the engine flags your plugin to update.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowEvent

WindowEvent(engine: Engine)

Bases: SceneEvent

Base window event implementation.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowCloseEvent

WindowCloseEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has closed.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowDisplayChangedEvent

WindowDisplayChangedEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window's display has changed.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowFocusGainedEvent

WindowFocusGainedEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has gained focus.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowFocusLostEvent

WindowFocusLostEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has lost focus.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowHiddenEvent

WindowHiddenEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has been hidden.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowMaximizedEvent

WindowMaximizedEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has been maximized.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowMinimizedEvent

WindowMinimizedEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has been minimized.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowMouseEnterEvent

WindowMouseEnterEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the mouse has entered the window.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowMouseLeaveEvent

WindowMouseLeaveEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the mouse has left the window.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowMovedEvent

WindowMovedEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has moved.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

position property

position: IntVector2

The position of the window.

WindowResizeEvent

WindowResizeEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has been resized.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

size property

size: IntVector2

The size of the window.

WindowRestoredEvent

WindowRestoredEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has been restored.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

WindowShownEvent

WindowShownEvent(engine: Engine)

Bases: WindowEvent

Dispatched when the scene recognizes that the window has been shown.

engine property

engine: Engine

The engine that is handling this plugin and dispatched this event.

scene property

scene: Scene

The active scene that dispatched this event.

on_event

on_event(
    event: type[Event],
    execution: ExecutionStep = ExecutionStep.AFTER,
) -> Callable[[Any], None]

Register a plugin to listen to a specific event at a desired execution step. Use as a decorator in a plugin implementation.

PARAMETER DESCRIPTION
event

Any ~Event-like object you would like to listen for.

TYPE: Event

execution

The desired time in which this event will be fired for the plugin to handle.

TYPE: ExecutionStep DEFAULT: ExecutionStep.AFTER