40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
|
|
||
|
from pygame.mixer import Sound, Channel
|
||
|
from pygame import mixer
|
||
|
import random
|
||
|
|
||
|
|
||
|
class Clackmanager:
|
||
|
|
||
|
clacks = []
|
||
|
|
||
|
channel1 = None
|
||
|
channel2 = None
|
||
|
|
||
|
def load(self):
|
||
|
self.clacks.append(Sound("audio/clack_01.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_02.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_03.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_04.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_05.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_06.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_07.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_08.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_09.ogg"))
|
||
|
self.clacks.append(Sound("audio/clack_10.ogg"))
|
||
|
|
||
|
self.channel1 = Channel(0)
|
||
|
self.channel2 = Channel(2)
|
||
|
|
||
|
def play_clack(self):
|
||
|
while True:
|
||
|
clack = random.choice(self.clacks)
|
||
|
if clack.get_num_channels() == 0:
|
||
|
break
|
||
|
if not self.channel1.get_busy():
|
||
|
self.channel1.play(clack)
|
||
|
print "played on 1"
|
||
|
elif not self.channel2.get_busy():
|
||
|
self.channel2.play(clack)
|
||
|
print "played on 2"
|