Main
Entrypoint for the Controller programm
CrazyComet            (Game)
        
Game class for the controller
Attributes:
| Name | Type | Description | 
|---|---|---|
score | 
int | 
Score of this player  | 
on_end(self)
async
Executed, when the game ends
Source code in src/main.py
async def on_end(self):
    self.rgb_leds.all_leds_blue()
on_exit(self, err=None)
async
Executed, when the game loop is exited
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
err | 
Exception | 
Value of the exception when the game exited with none zero code  | 
None | 
Source code in src/main.py
async def on_exit(self, err: Exception = None):
    self.rgb_leds.switch_off_leds()
    return await super().on_exit(err)
on_init(self)
async
Initialize controls
Source code in src/main.py
async def on_init(self):
    """
        Initialize controls
    """
    self.rgb_leds = LEDControl()
    self.ready_control = {
        "key": KeyCode.BUT_1,
        "input": ReadyControl(seat=self.config["seat"], name="Ready Control", led_ctl=self.rgb_leds)}
    self.controls = {
        JoystickCode.LEFT_Y: VerticalTurretControl(
            seat=self.config["seat"],
            name="vertical_control",
            pin=13,
            config=self.config['CrazyComet']['turrets']['vertical']
        ),
        JoystickCode.LEFT_X: HorizontalTurretControl(
            seat=self.config["seat"],
            name="horizontal_control",
            pin=12,
            rgb_cb=self.rgb_leds.display_joystick_pos,
            config=self.config['CrazyComet']['turrets']['horizontal']
        ),
        KeyCode.R1: Blaster(
            seat=1,
            name="Blaster",
            score_cb=self.update_score,
            magazine_size=self.config['CrazyComet']['blaster']['magazine_size'],
            inverted_logic=self.config['CrazyComet']['blaster']['inverted_logic'],
            led_cb=self.rgb_leds.score_leds
        )
    }
on_pregame(self)
async
Reset score
Source code in src/main.py
async def on_pregame(self):
    """
        Reset score
    """
    self.score = 0
update_score(self)
async
Increase score by one and publish it with gameIO
Source code in src/main.py
async def update_score(self):
    """
        Increase score by one and publish it with gameIO
    """
    self.score += 1
    await self.game_io.score(score=self.score, seat=self.config["seat"])