-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSoundEffect.py
48 lines (37 loc) · 1.59 KB
/
SoundEffect.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
41
42
43
44
45
46
47
48
import pygame
class SoundEffect:
def __init__(self):
pygame.mixer.init()
self.shoot = pygame.mixer.Sound("SoundEffects/shoot.wav")
self.shoot.set_volume(0.15)
self.fastInvader1 = pygame.mixer.Sound("SoundEffects/fastinvader1.wav")
self.fastInvader1.set_volume(0.3)
self.fastInvader2 = pygame.mixer.Sound("SoundEffects/fastinvader2.wav")
self.fastInvader2.set_volume(0.3)
self.fastInvader3 = pygame.mixer.Sound("SoundEffects/fastinvader3.wav")
self.fastInvader3.set_volume(0.3)
self.fastInvader4 = pygame.mixer.Sound("SoundEffects/fastinvader4.wav")
self.fastInvader4.set_volume(0.3)
self.explosion = pygame.mixer.Sound("SoundEffects/explosion.wav")
self.explosion.set_volume(0.2)
self.invaderKilled = pygame.mixer.Sound("SoundEffects/invaderkilled.wav")
self.invaderKilled.set_volume(0.15)
self.timerLength = 60
self.timer = 59
self.currentSongIndex = 3;
def playSong(self):
self.timer += 1
if self.timer >= self.timerLength:
self.timer = 0
if (self.currentSongIndex == 0):
self.fastInvader1.play()
elif (self.currentSongIndex == 1):
self.fastInvader2.play()
elif (self.currentSongIndex == 2):
self.fastInvader3.play()
elif (self.currentSongIndex == 3):
self.fastInvader4.play()
if (self.currentSongIndex < 3):
self.currentSongIndex += 1
else:
self.currentSongIndex = 0