play sound

This commit is contained in:
CoCo_Sol 2023-10-29 12:27:21 +01:00
parent 651855f2fa
commit cda7cbcc59

View file

@ -566,6 +566,7 @@ class Sound:
def __init__(self, name: str) -> None:
self.name = name
self._is_paying = False
class Scene:
@ -771,6 +772,15 @@ def start_game(
),
)
# On met le son
for entity in world.query(Sound):
# On verifie si le son est deja actif.
if not entity[Sound]._is_paying:
# On charge le son et on le joue.
if os.path.exists("assets/sounds/" + entity[Sound].name):
entity[Sound]._is_paying = True
pygame.mixer.Sound("assets/sounds/" + entity[Sound].name).play()
# Mise a jour de la fenêtre
rect = Display._calculate_surface_rect()
pygame.transform.set_smoothscale_backend("MMX")