mirror of
https://github.com/apirrone/Open_Duck_Mini_Runtime.git
synced 2025-09-05 05:27:49 +00:00
cleaning up
This commit is contained in:
parent
0d2a45f3cd
commit
a875b7c6f7
1 changed files with 12 additions and 9 deletions
|
@ -10,15 +10,18 @@ class Sounds:
|
||||||
pygame.mixer.music.set_volume(volume)
|
pygame.mixer.music.set_volume(volume)
|
||||||
self.sounds = {}
|
self.sounds = {}
|
||||||
self.ok = True
|
self.ok = True
|
||||||
|
try:
|
||||||
for file in os.listdir(sound_directory):
|
for file in os.listdir(sound_directory):
|
||||||
if file.endswith(".wav"):
|
if file.endswith(".wav"):
|
||||||
sound_path = os.path.join(sound_directory, file)
|
sound_path = os.path.join(sound_directory, file)
|
||||||
try:
|
try:
|
||||||
self.sounds[file] = pygame.mixer.Sound(sound_path)
|
self.sounds[file] = pygame.mixer.Sound(sound_path)
|
||||||
print(f"Loaded: {file}")
|
print(f"Loaded: {file}")
|
||||||
except pygame.error as e:
|
except pygame.error as e:
|
||||||
print(f"Failed to load {file}: {e}")
|
print(f"Failed to load {file}: {e}")
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"Directory {sound_directory} not found.")
|
||||||
|
self.ok = False
|
||||||
if len(self.sounds) == 0:
|
if len(self.sounds) == 0:
|
||||||
print("No sound files found in the directory.")
|
print("No sound files found in the directory.")
|
||||||
self.ok = False
|
self.ok = False
|
||||||
|
|
Loading…
Reference in a new issue