""" Bootstrap helpers for initializing Pygame with project defaults. This keeps startup logic separate from the gameplay code so we can evolve menus and settings without touching the core loop. """ from __future__ import annotations import os from typing import Dict, Tuple from config import constants from config.settings_schema import DEFAULT_SETTINGS os.environ.setdefault("PYGAME_HIDE_SUPPORT_PROMPT", "1") def init_pygame(settings: Dict[str, object] | None = None): import pygame pygame.init() try: pygame.mixer.init() except Exception: # Audio is optional; game will still run without mixer. pass data = dict(DEFAULT_SETTINGS) if settings: data.update(settings) resolution: Tuple[int, int] = data.get("resolution", constants.BASE_RESOLUTION) # type: ignore[assignment] flags = pygame.FULLSCREEN if data.get("fullscreen") else 0 screen = pygame.display.set_mode(resolution, flags) pygame.display.set_caption("SCRAP COLLECTOR - Prototype") clock = pygame.time.Clock() return screen, clock, data