diff options
Diffstat (limited to 'src/splitscreen_duo/games/breakout.py')
| -rw-r--r-- | src/splitscreen_duo/games/breakout.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/splitscreen_duo/games/breakout.py b/src/splitscreen_duo/games/breakout.py index 734b394..ef369de 100644 --- a/src/splitscreen_duo/games/breakout.py +++ b/src/splitscreen_duo/games/breakout.py @@ -21,8 +21,8 @@ logger = logging.getLogger(__name__) class Breakout(GameBase): - def __init__(self, screen, serial, instance): - super().__init__(screen, serial, instance) + def __init__(self, screen, serial, instance, is_joint_mode=False): + super().__init__(screen, serial, instance, is_joint_mode) self.screen_width = screen.get_width() self.screen_height = screen.get_height() @@ -65,6 +65,7 @@ class Breakout(GameBase): if self.ball[0] <= BALL_SIZE or self.ball[0] >= self.screen_width - BALL_SIZE: self.ball_dx *= -1 + if self.ball[1] <= BALL_SIZE: self.ball_dy *= -1 @@ -90,6 +91,9 @@ class Breakout(GameBase): self.bricks.remove(brick) self.score += 1 + + self.send_stats(self.score) + self.ball_dy *= -1 logger.debug(f"brick hit, score: {self.score}") @@ -156,9 +160,11 @@ class Breakout(GameBase): for brick in self.bricks: pygame.draw.rect(self.screen, RED, brick) - score_text = self.font.render(f"Score: {self.score}", True, WHITE) + if not self.is_joint_mode or self.instance != "primary": + score_text = self.font.render(f"Score: {self.score}", True, WHITE) + + self.screen.blit(score_text, (10, 10)) - self.screen.blit(score_text, (10, 10)) pygame.display.flip() clock.tick(60) |