SPACE INVADERS 9

Music:

...

from rstem.sound import Sound, Note

from itertools import cycle

...

fire_sound = Sound("/home/pi/fire.wav")

hit_sound = Sound("/home/pi/hit.wav")

notes = cycle([Note('B3'), Note('G3'), Note('E3'), Note('C3')])

...



while True:

...

# Button was pressed - launch missile

...

fire_sound.play()

...

# Move alien

if ...:

next(notes).play(duration=0.20)

...

# Check for collision

if ...:

...

hit_sound.play()



Full project:

prev| next