PygameRenderingEngine

This module provides a rendering engine using the pygame library. It creates a window and displays the game in it. The window itself is built and run by the gui package, in a separate process, so that drawing never slows the game down.

class PygameRenderingEngine(fullscreen=False, trace_length=0, *args, **kwargs)[source]

(This class inherits from RenderingEngine ).

This rendering engine uses the pygame library to render the game. It creates a window and displays the game in it.

The window runs in a different process than the one running the game, and receives the successive states of the game through a queue. It shows the moves at its own pace, set by the rendering_speed argument, and not at the pace of the game. The window may therefore lag behind the game, and catches up once the game is over.

__init__(fullscreen=False, trace_length=0, *args, **kwargs)[source]

Initializes a new instance of the class.

Parameters:
  • fullscreen (bool) – Indicates if the GUI should be fullscreen.

  • trace_length (int) – Length of the trace to display.

  • *args (object) – Arguments to pass to the parent constructor.

  • **kwargs (object) – Keyword arguments to pass to the parent constructor.

end()[source]

(This method redefines the method of the parent class with the same name).

It waits for the window to be closed before exiting.

Return type:

None

render(players, maze, game_state)[source]

(This method redefines the method of the parent class with the same name).

This function renders the game to a pygame window. The window is created in a different process than the one running the game.

Parameters:
  • players (list[Player]) – Players of the game.

  • maze (Maze) – Maze of the game.

  • game_state (GameState) – State of the game.

Raises:

PyRatException – If no player is given, if a player is not in the game state, or if the window could not be opened.

Return type:

None