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
pygamelibrary 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_speedargument, 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
pygamewindow. The window is created in a different process than the one running the game.- Parameters:
- 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