mini_arcade_core.runtime.input_frame

Input frame data structure for capturing input state per frame.

Classes

ButtonState

State of a single action button.

InputFrame

Snapshot of input state for a single frame.

Module Contents

class mini_arcade_core.runtime.input_frame.ButtonState

State of a single action button.

Variables:
  • (bool) (released) – Whether the button is currently held down.

  • (bool) – Whether the button was pressed this frame.

  • (bool) – Whether the button was released this frame.

down: bool
pressed: bool
released: bool
to_dict() Dict[str, bool]

Convert the ButtonState to a dictionary.

Returns:

Dictionary representation of the ButtonState.

Return type:

Dict[str, bool]

classmethod from_dict(data: Dict[str, bool]) ButtonState

Create a ButtonState from a dictionary.

Parameters:

data (Dict[str, bool]) – Dictionary containing button state data.

Returns:

ButtonState instance.

Return type:

ButtonState

class mini_arcade_core.runtime.input_frame.InputFrame

Snapshot of input state for a single frame.

Variables:
  • (int) (frame_index) – Sequential index of the frame.

  • (float) (dt) – Delta time since the last frame in seconds.

  • (FrozenSet[Key]) (keys_released) – Set of currently held down keys.

  • (FrozenSet[Key]) – Set of keys pressed this frame.

  • (FrozenSet[Key]) – Set of keys released this frame.

  • ButtonState]) (buttons (Dict[str,) – Mapping of action button names to their states.

  • float]) (axes (Dict[str,) – Mapping of axis names to their float values.

  • int]) (mouse_delta (Tuple[int,) – Current mouse position (x, y).

  • int]) – Mouse movement delta (dx, dy)

  • (str) (text_input) – Text input entered this frame.

  • (bool) (quit) – Whether a quit request was made this frame.

frame_index: int
dt: float
keys_down: FrozenSet[mini_arcade_core.backend.keys.Key]
keys_pressed: FrozenSet[mini_arcade_core.backend.keys.Key]
keys_released: FrozenSet[mini_arcade_core.backend.keys.Key]
buttons: Dict[str, ButtonState]
axes: Dict[str, float]
mouse_pos: Tuple[int, int] = (0, 0)
mouse_delta: Tuple[int, int] = (0, 0)
text_input: str = ''
quit: bool = False
to_dict() Dict[str, object]

Convert the InputFrame to a dictionary.

Returns:

Dictionary representation of the InputFrame.

Return type:

Dict[str, object]

classmethod from_dict(data: Dict[str, object]) InputFrame

Create an InputFrame from a dictionary.

Parameters:

data (Dict[str, object]) – Dictionary containing input frame data.

Returns:

InputFrame instance.

Return type:

InputFrame