pyrat.src.RenderingEngine
This file is part of the PyRat library. It is meant to be used as a library, and not to be executed directly.
Please import necessary elements using the following syntax:
from pyrat import
1##################################################################################################################################################### 2######################################################################## INFO ####################################################################### 3##################################################################################################################################################### 4 5""" 6 This file is part of the PyRat library. 7 It is meant to be used as a library, and not to be executed directly. 8 Please import necessary elements using the following syntax: 9 from pyrat import <element_name> 10""" 11 12##################################################################################################################################################### 13###################################################################### IMPORTS ###################################################################### 14##################################################################################################################################################### 15 16# External imports 17from typing import * 18from typing_extensions import * 19from numbers import * 20 21# PyRat imports 22from pyrat.src.Player import Player 23from pyrat.src.Maze import Maze 24from pyrat.src.GameState import GameState 25 26##################################################################################################################################################### 27###################################################################### CLASSES ###################################################################### 28##################################################################################################################################################### 29 30class RenderingEngine (): 31 32 """ 33 A rendering engine is an object that can render a PyRat game. 34 By defaut, this engine renders nothing, which is a valid rendering mode for a PyRat game. 35 Inherit from this class to create a rendering engine that does something. 36 """ 37 38 ############################################################################################################################################# 39 # MAGIC METHODS # 40 ############################################################################################################################################# 41 42 def __init__ ( self: Self, 43 render_simplified: bool = False 44 ) -> Self: 45 46 """ 47 This function is the constructor of the class. 48 When an object is instantiated, this method is called to initialize the object. 49 This is where you should define the attributes of the object and set their initial values. 50 In: 51 * self: Reference to the current object. 52 * render_simplified: Whether to render the simplified version of the game. 53 Out: 54 * A new instance of the class. 55 """ 56 57 # Debug 58 assert isinstance(render_simplified, bool) # Type check for render_simplified 59 60 # Protected attributes 61 self._render_simplified = render_simplified 62 63 ############################################################################################################################################# 64 # PUBLIC METHODS # 65 ############################################################################################################################################# 66 67 def render ( self: Self, 68 players: List[Player], 69 maze: Maze, 70 game_state: GameState, 71 ) -> None: 72 73 """ 74 This method does nothing. 75 Redefine it in the child classes to render the game somehow. 76 In: 77 * self: Reference to the current object. 78 * players: PLayers of the game. 79 * maze: Maze of the game. 80 * game_state: State of the game. 81 Out: 82 * None. 83 """ 84 85 # Debug 86 assert isinstance(players, list) # Type check for players 87 assert all(isinstance(player, Player) for player in players) 88 assert isinstance(maze, Maze) 89 assert isinstance(game_state, GameState) 90 91 # Nothing to do 92 pass 93 94 ############################################################################################################################################# 95 96 def end ( self: Self, 97 ) -> None: 98 99 """ 100 This method does nothing. 101 Redefine it in the child classes to do something when the game ends if needed. 102 In: 103 * self: Reference to the current object. 104 Out: 105 * None. 106 """ 107 108 # Nothing to do 109 pass 110 111##################################################################################################################################################### 112#####################################################################################################################################################
31class RenderingEngine (): 32 33 """ 34 A rendering engine is an object that can render a PyRat game. 35 By defaut, this engine renders nothing, which is a valid rendering mode for a PyRat game. 36 Inherit from this class to create a rendering engine that does something. 37 """ 38 39 ############################################################################################################################################# 40 # MAGIC METHODS # 41 ############################################################################################################################################# 42 43 def __init__ ( self: Self, 44 render_simplified: bool = False 45 ) -> Self: 46 47 """ 48 This function is the constructor of the class. 49 When an object is instantiated, this method is called to initialize the object. 50 This is where you should define the attributes of the object and set their initial values. 51 In: 52 * self: Reference to the current object. 53 * render_simplified: Whether to render the simplified version of the game. 54 Out: 55 * A new instance of the class. 56 """ 57 58 # Debug 59 assert isinstance(render_simplified, bool) # Type check for render_simplified 60 61 # Protected attributes 62 self._render_simplified = render_simplified 63 64 ############################################################################################################################################# 65 # PUBLIC METHODS # 66 ############################################################################################################################################# 67 68 def render ( self: Self, 69 players: List[Player], 70 maze: Maze, 71 game_state: GameState, 72 ) -> None: 73 74 """ 75 This method does nothing. 76 Redefine it in the child classes to render the game somehow. 77 In: 78 * self: Reference to the current object. 79 * players: PLayers of the game. 80 * maze: Maze of the game. 81 * game_state: State of the game. 82 Out: 83 * None. 84 """ 85 86 # Debug 87 assert isinstance(players, list) # Type check for players 88 assert all(isinstance(player, Player) for player in players) 89 assert isinstance(maze, Maze) 90 assert isinstance(game_state, GameState) 91 92 # Nothing to do 93 pass 94 95 ############################################################################################################################################# 96 97 def end ( self: Self, 98 ) -> None: 99 100 """ 101 This method does nothing. 102 Redefine it in the child classes to do something when the game ends if needed. 103 In: 104 * self: Reference to the current object. 105 Out: 106 * None. 107 """ 108 109 # Nothing to do 110 pass
A rendering engine is an object that can render a PyRat game. By defaut, this engine renders nothing, which is a valid rendering mode for a PyRat game. Inherit from this class to create a rendering engine that does something.
43 def __init__ ( self: Self, 44 render_simplified: bool = False 45 ) -> Self: 46 47 """ 48 This function is the constructor of the class. 49 When an object is instantiated, this method is called to initialize the object. 50 This is where you should define the attributes of the object and set their initial values. 51 In: 52 * self: Reference to the current object. 53 * render_simplified: Whether to render the simplified version of the game. 54 Out: 55 * A new instance of the class. 56 """ 57 58 # Debug 59 assert isinstance(render_simplified, bool) # Type check for render_simplified 60 61 # Protected attributes 62 self._render_simplified = render_simplified
This function is the constructor of the class. When an object is instantiated, this method is called to initialize the object. This is where you should define the attributes of the object and set their initial values.
In:
- self: Reference to the current object.
- render_simplified: Whether to render the simplified version of the game.
Out:
- A new instance of the class.
68 def render ( self: Self, 69 players: List[Player], 70 maze: Maze, 71 game_state: GameState, 72 ) -> None: 73 74 """ 75 This method does nothing. 76 Redefine it in the child classes to render the game somehow. 77 In: 78 * self: Reference to the current object. 79 * players: PLayers of the game. 80 * maze: Maze of the game. 81 * game_state: State of the game. 82 Out: 83 * None. 84 """ 85 86 # Debug 87 assert isinstance(players, list) # Type check for players 88 assert all(isinstance(player, Player) for player in players) 89 assert isinstance(maze, Maze) 90 assert isinstance(game_state, GameState) 91 92 # Nothing to do 93 pass
This method does nothing. Redefine it in the child classes to render the game somehow.
In:
- self: Reference to the current object.
- players: PLayers of the game.
- maze: Maze of the game.
- game_state: State of the game.
Out:
- None.
97 def end ( self: Self, 98 ) -> None: 99 100 """ 101 This method does nothing. 102 Redefine it in the child classes to do something when the game ends if needed. 103 In: 104 * self: Reference to the current object. 105 Out: 106 * None. 107 """ 108 109 # Nothing to do 110 pass
This method does nothing. Redefine it in the child classes to do something when the game ends if needed.
In:
- self: Reference to the current object.
Out:
- None.