@@ -60,6 +60,8 @@ def __init__(self, x_pos, groups):
60
60
self .velocity = random .randint (3 , 10 )
61
61
62
62
self .add (groups )
63
+ self .explosion_sound = pygame .mixer .Sound ("Arcade Explo A.wav" )
64
+ self .explosion_sound .set_volume (0.4 )
63
65
64
66
def update (self ):
65
67
x , y = self .rect .center
@@ -72,6 +74,11 @@ def update(self):
72
74
73
75
self .rect .center = x , y
74
76
77
+ def kill (self ):
78
+ x , y = self .rect .center
79
+ if pygame .mixer .get_init ():
80
+ self .explosion_sound .play (maxtime = 1000 )
81
+ super (EnemySprite , self ).kill ()
75
82
class StatusSprite (pygame .sprite .Sprite ):
76
83
def __init__ (self , ship , groups ):
77
84
super (StatusSprite , self ).__init__ ()
@@ -153,6 +160,7 @@ def create_starfield(group):
153
160
154
161
def main ():
155
162
pygame .font .init ()
163
+ pygame .mixer .init ()
156
164
screen = pygame .display .set_mode ((X_MAX , Y_MAX ), DOUBLEBUF )
157
165
everything = pygame .sprite .Group ()
158
166
enemies = pygame .sprite .Group ()
@@ -173,6 +181,14 @@ def main():
173
181
for i in range (10 ):
174
182
pos = random .randint (0 , X_MAX )
175
183
EnemySprite (pos , [everything , enemies ])
184
+
185
+ # Get some music
186
+ if pygame .mixer .get_init ():
187
+ pygame .mixer .music .load ("DST-AngryMod.mp3" )
188
+ pygame .mixer .music .set_volume (0.8 )
189
+ pygame .mixer .music .play (- 1 )
190
+
191
+
176
192
177
193
178
194
while True :
0 commit comments