diff options
Diffstat (limited to 'src/splitscreen_duo/games/breakout.py')
| -rw-r--r-- | src/splitscreen_duo/games/breakout.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/splitscreen_duo/games/breakout.py b/src/splitscreen_duo/games/breakout.py index 3f6aa16..6a5e2cc 100644 --- a/src/splitscreen_duo/games/breakout.py +++ b/src/splitscreen_duo/games/breakout.py @@ -23,12 +23,27 @@ logger = logging.getLogger(__name__) class Breakout(GameBase): 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() - self.reset() def reset(self): + global PADDLE_WIDTH, PADDLE_HEIGHT, BALL_SIZE, BRICK_WIDTH, BRICK_HEIGHT, BRICK_ROWS, BRICK_COLS, SPEED + + scale_factor = min(self.screen_width / 640, self.screen_height / 480) + + if self.is_vertical: + PADDLE_WIDTH = min(100, int(80 * scale_factor)) + BRICK_COLS = max(5, min(8, int(self.screen_width / 90))) + else: + PADDLE_WIDTH = min(100, int(100 * scale_factor)) + BRICK_COLS = max(6, min(10, int(self.screen_width / 90))) + + PADDLE_HEIGHT = max(8, int(10 * scale_factor)) + BALL_SIZE = max(6, int(10 * scale_factor)) + BRICK_WIDTH = int((self.screen_width - 20) / BRICK_COLS) - 5 + BRICK_HEIGHT = max(15, min(30, int(30 * scale_factor))) + BRICK_ROWS = max(3, min(5, int(self.screen_height / 120))) + SPEED = max(3, min(5, int(5 * scale_factor))) + self.paddle = [ self.screen_width // 2 - PADDLE_WIDTH // 2, self.screen_height - 40, @@ -163,7 +178,10 @@ class Breakout(GameBase): 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)) + if self.is_vertical: + self.screen.blit(score_text, (self.screen_width // 2 - score_text.get_width() // 2, 10)) + else: + self.screen.blit(score_text, (10, 10)) pygame.display.flip() clock.tick(60) |