-
Notifications
You must be signed in to change notification settings - Fork 0
/
sound.py
41 lines (28 loc) · 982 Bytes
/
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
31
32
33
34
35
36
37
38
39
40
#####################################################
#
# breakout game with pygame
# for Python stage in Technofutur TIC (Belgium)
# Authors : Bastien Wiaux and Benoit Ronval
#
#####################################################
import pygame
pygame.init()
# Charge les differents fichiers audio
death_sound = pygame.mixer.Sound("death_sound.mp3")
touch_ball = pygame.mixer.Sound("player_sound.mp3")
brick_sound = pygame.mixer.Sound("brick_sound.mp3")
victory_sound = pygame.mixer.Sound("victory.mp3")
# Diminue le volume
pygame.mixer.Sound.set_volume(death_sound, 0.7)
pygame.mixer.Sound.set_volume(touch_ball, 0.7)
pygame.mixer.Sound.set_volume(brick_sound, 0.7)
pygame.mixer.Sound.set_volume(victory_sound, 0.7)
# Pour jouer les effets sonores
def touch():
pygame.mixer.Sound.play(touch_ball)
def death():
pygame.mixer.Sound.play(death_sound)
def brick():
pygame.mixer.Sound.play(brick_sound)
def victory():
pygame.mixer.Sound.play(victory_sound)