Commit 5ca86a65 authored by Alan Aguiar's avatar Alan Aguiar
Browse files

play sounds

parent e4a0ea3a
......@@ -54,10 +54,13 @@ class Flappy():
def __init__(self):
self.state = INIT
self.best = 0
self.sound = True
def increment_score(self):
self.score = self.score + 1
self.currentS.set_score(self.score)
if self.sound:
self._snd_pipe.play()
def load_all(self):
self.game_w = GAME_SIZE[0]
......@@ -110,6 +113,7 @@ class Flappy():
def main(self):
pygame.display.init()
pygame.font.init()
pygame.mixer.init()
self.clock = pygame.time.Clock()
self.screen = pygame.display.get_surface()
if self.screen:
......@@ -122,6 +126,10 @@ class Flappy():
else:
self.screen = pygame.display.set_mode(GAME_SIZE)
pygame.display.set_caption('Flappy')
self._snd_pipe = pygame.mixer.Sound('sounds/pipe.ogg')
self._snd_pipe.set_volume(0.5)
self._snd_bird = pygame.mixer.Sound('sounds/bird.ogg')
self._snd_bird.set_volume(0.5)
self.load_all()
self.state = INIT
self.running = True
......@@ -137,6 +145,8 @@ class Flappy():
self.load_game()
elif self.state == PLAY:
self.bird.setVel(8)
if self.sound:
self._snd_bird.play()
elif self.state == END:
self.state = INIT
self.load_all()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment