예제 #1
0
 def stop_playing(self, sound: pygame.mixer.Sound, fade_ms=0):
     if not PLAY_SOUNDS:
         return
     if sound not in self.playing_sounds:
         return
     if self.playing_sounds[sound].get_busy():
         if fade_ms:
             sound.fadeout(fade_ms)
         else:
             sound.stop()
예제 #2
0
    def play_sound(self, sound: pygame.mixer.Sound):
        """
        Plays the sound with volume proportional to distance to player

        If that sound is already played, it is stopped and played again with better volume
        This is done to remove sounds ugly overlaying

        :param sound: sound to play
        :return: None
        """
        # The volume is calculated as a upside-down parabola
        # pygame converts negative volume to 1
        volume = max(
            0,
            -0.000001 * (self.game.player.pos - self.pos).length_squared() + 1)
        if sound.get_num_channels() == 0 or sound.get_volume() < volume:
            sound.stop()
            sound.set_volume(volume)
            sound.play()
예제 #3
0
파일: g2d.py 프로젝트: danilopag/Frogger
def pause_audio(audio: pygame.mixer.Sound) -> None:
    audio.stop()
예제 #4
0
파일: g2d_pyg.py 프로젝트: tomamic/fondinfo
def pause_audio(audio: pygame.mixer.Sound) -> None:
    audio.stop()