-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathSound.py
30 lines (24 loc) · 1.02 KB
/
Sound.py
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
from pygame import mixer
class Sound:
def __init__(self):
self.music_channel = mixer.Channel(0)
self.music_channel.set_volume(0.2)
self.sfx_channel = mixer.Channel(1)
self.sfx_channel.set_volume(0.2)
self.allowSFX = True
self.soundtrack = mixer.Sound("./sfx/main_theme.ogg")
self.coin = mixer.Sound("./sfx/coin.ogg")
self.bump = mixer.Sound("./sfx/bump.ogg")
self.stomp = mixer.Sound("./sfx/stomp.ogg")
self.jump = mixer.Sound("./sfx/small_jump.ogg")
self.death = mixer.Sound("./sfx/death.wav")
self.kick = mixer.Sound("./sfx/kick.ogg")
self.brick_bump = mixer.Sound("./sfx/brick-bump.ogg")
self.powerup = mixer.Sound('./sfx/powerup.ogg')
self.powerup_appear = mixer.Sound('./sfx/powerup_appears.ogg')
self.pipe = mixer.Sound('./sfx/pipe.ogg')
def play_sfx(self, sfx):
if self.allowSFX:
self.sfx_channel.play(sfx)
def play_music(self, music):
self.music_channel.play(music)