Game
Class to control the whole game. Inherit from this class and call run()
to start your gamecontrol
players
property
readonly
Instance of Player
used to acces player information
on_score(self)
async
Executed, when a player scores one or more points
Source code in game_sdk/gamecontrol/game.py
async def on_score(self):
"""
Executed, when a player scores one or more points
"""
logging.info("ON SCORE")
set_game_state(self, state)
async
Set game_state
and execute the coresponding function
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
GameState |
State to which to switch |
required |
Source code in game_sdk/gamecontrol/game.py
async def set_game_state(self, state: GameState):
"""
Set `game_state` and execute the coresponding function
Arguments:
state: State to which to switch
"""
self._game_state = state
if self._game_state == GameState.START:
asyncio.create_task(self.on_pregame())
if self._game_state == GameState.RUN:
asyncio.create_task(self.on_start())
if self._game_state == GameState.END:
asyncio.create_task(self._on_end())
asyncio.create_task(self._game_io.set_game_state(self._game_state))