escapy.pygame

pygame submodule for escapy.

This submodule contains the PyGameUi implementation.

class escapy.pygame.PyGameUi(config, message_provider)[source]

Bases: GameUiProtocol

Pygame-based game UI.

Manages the display window, input handling, and rendering. Three distinct internal states control how input is interpreted:

  • Normal – clicks on room objects or inventory items.

  • InsertCode – keyboard input for a code prompt.

  • Inspect – fullscreen view of an object image.

Parameters:
  • config (dict) – UI configuration dictionary (window size, asset paths, layout fractions, etc.).

  • message_provider (MessageProvider) – Callable that maps events to display strings.

init(game)[source]

Bind the UI to a GameProtocol and start running.

Parameters:

game (GameProtocol)

tick()[source]

Advance the clock to regulate the frame rate.

input()[source]

Process all pending pygame events and return game events.

Return type:

list[Event]

render()[source]

Draw the current frame (room, objects, inventory, overlays).

handle(events)[source]

React to game events by updating messages and UI state.

Parameters:

events (list[Event])

Return type:

None

quit()[source]

Shut down the pygame display.

Return type:

None

add_message(message)[source]

Add a message to the message list.

Parameters:

message (str)

Return type:

None

Submodules

escapy.pygame.pygame_ui

Pygame-based UI implementation for escapy.

Provides PyGameUi, a concrete implementation of GameUiProtocol that renders the game using pygame. The UI is split into three screen regions: the main game area, an inventory sidebar, and a message bar.

class escapy.pygame.pygame_ui.PyGameUi(config, message_provider)[source]

Bases: GameUiProtocol

Pygame-based game UI.

Manages the display window, input handling, and rendering. Three distinct internal states control how input is interpreted:

  • Normal – clicks on room objects or inventory items.

  • InsertCode – keyboard input for a code prompt.

  • Inspect – fullscreen view of an object image.

Parameters:
  • config (dict) – UI configuration dictionary (window size, asset paths, layout fractions, etc.).

  • message_provider (MessageProvider) – Callable that maps events to display strings.

init(game)[source]

Bind the UI to a GameProtocol and start running.

Parameters:

game (GameProtocol)

tick()[source]

Advance the clock to regulate the frame rate.

input()[source]

Process all pending pygame events and return game events.

Return type:

list[Event]

render()[source]

Draw the current frame (room, objects, inventory, overlays).

handle(events)[source]

React to game events by updating messages and UI state.

Parameters:

events (list[Event])

Return type:

None

quit()[source]

Shut down the pygame display.

Return type:

None

add_message(message)[source]

Add a message to the message list.

Parameters:

message (str)

Return type:

None