diff --git a/display.py b/display.py index c9753be..fc4442d 100644 --- a/display.py +++ b/display.py @@ -88,13 +88,55 @@ def initialize_gui(gameTitle): Speech.get_instance().speak("Error loading sounds.", False) soundData = {} - # Play intro sound if available + # Play intro sound if available, optionally with visual logo from .sound import cut_scene if 'game-intro' in soundData: - cut_scene(soundData, 'game-intro') + _show_logo_with_audio(soundData, 'game-intro') return soundData +def _show_logo_with_audio(soundData, audioKey): + """Show visual logo while playing audio intro. + + Args: + soundData (dict): Dictionary of loaded sounds + audioKey (str): Key of the audio to play + """ + # Look for logo image files in common formats + logoFiles = ['logo.png', 'logo.jpg', 'logo.jpeg', 'logo.gif', 'logo.bmp'] + logoImage = None + + for logoFile in logoFiles: + if os.path.exists(logoFile): + try: + logoImage = pygame.image.load(logoFile) + break + except pygame.error: + continue + + if logoImage: + # Display logo while audio plays + screen = pygame.display.get_surface() + screenRect = screen.get_rect() + logoRect = logoImage.get_rect(center=screenRect.center) + + # Clear screen to black + screen.fill((0, 0, 0)) + screen.blit(logoImage, logoRect) + pygame.display.flip() + + # Play audio and wait for it to finish + from .sound import cut_scene + cut_scene(soundData, audioKey) + + # Clear screen after audio finishes + screen.fill((0, 0, 0)) + pygame.display.flip() + else: + # No logo image found, just play audio + from .sound import cut_scene + cut_scene(soundData, audioKey) + def display_text(text): """Display and speak text with navigation controls. diff --git a/utils.py b/utils.py index 4c0092e..9b06611 100644 --- a/utils.py +++ b/utils.py @@ -111,12 +111,51 @@ class Game: # Load sound effects self.sound - # Play intro sound if available + # Play intro sound if available, optionally with visual logo if 'game-intro' in self.sound.sounds: - self.sound.cut_scene('game-intro') + self._show_logo_with_audio('game-intro') return self + def _show_logo_with_audio(self, audioKey): + """Show visual logo while playing audio intro. + + Args: + audioKey (str): Key of the audio to play + """ + # Look for logo image files in common formats + logoFiles = ['logo.png', 'logo.jpg', 'logo.jpeg', 'logo.gif', 'logo.bmp'] + logoImage = None + + for logoFile in logoFiles: + if os.path.exists(logoFile): + try: + logoImage = pygame.image.load(logoFile) + break + except pygame.error: + continue + + if logoImage: + # Display logo while audio plays + screen = pygame.display.get_surface() + screenRect = screen.get_rect() + logoRect = logoImage.get_rect(center=screenRect.center) + + # Clear screen to black + screen.fill((0, 0, 0)) + screen.blit(logoImage, logoRect) + pygame.display.flip() + + # Play audio and wait for it to finish + self.sound.cut_scene(audioKey) + + # Clear screen after audio finishes + screen.fill((0, 0, 0)) + pygame.display.flip() + else: + # No logo image found, just play audio + self.sound.cut_scene(audioKey) + def speak(self, text, interrupt=True): """Speak text using the speech system.