-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsound.py
More file actions
56 lines (49 loc) · 2.29 KB
/
sound.py
File metadata and controls
56 lines (49 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pygame as pg
import os
class Sound:
def __init__(self, game):
self.game = game
pg.mixer.init()
self.path = 'resources/sound/'
self.sounds = {}
try:
# Carrega os sons dos NPCs
if os.path.exists(self.path + 'npc_shot.wav'):
self.npc_shot = pg.mixer.Sound(self.path + 'npc_shot.wav')
self.npc_shot.set_volume(0.2)
else:
print("Arquivo de som não encontrado:", self.path + 'npc_shot.wav')
self.npc_shot = None
if os.path.exists(self.path + 'npc_pain.wav'):
self.npc_pain = pg.mixer.Sound(self.path + 'npc_pain.wav')
self.npc_pain.set_volume(0.2)
else:
print("Arquivo de som não encontrado:", self.path + 'npc_pain.wav')
self.npc_pain = None
if os.path.exists(self.path + 'npc_death.wav'):
self.npc_death = pg.mixer.Sound(self.path + 'npc_death.wav')
self.npc_death.set_volume(0.2)
else:
print("Arquivo de som não encontrado:", self.path + 'npc_death.wav')
self.npc_death = None
# Sons do jogador
if os.path.exists(self.path + 'shotgun.wav'):
self.player_shot = pg.mixer.Sound(self.path + 'shotgun.wav')
self.player_shot.set_volume(0.2)
else:
print("Arquivo de som não encontrado:", self.path + 'shotgun.wav')
self.player_shot = None
if os.path.exists(self.path + 'player_pain.wav'):
self.player_pain = pg.mixer.Sound(self.path + 'player_pain.wav')
self.player_pain.set_volume(0.2)
else:
print("Arquivo de som não encontrado:", self.path + 'player_pain.wav')
self.player_pain = None
# Música tema
if os.path.exists(self.path + 'theme.mp3'):
pg.mixer.music.load(self.path + 'theme.mp3')
pg.mixer.music.set_volume(0.2)
else:
print("Arquivo de som não encontrado:", self.path + 'theme.mp3')
except Exception as e:
print("Erro ao carregar sons:", str(e))