diff --git a/activity.py b/activity.py index 79c1acd..0dbaaf2 100755 --- a/activity.py +++ b/activity.py @@ -50,7 +50,7 @@ def __init__(self, handle): self.game = main.Game(self) self.build_toolbar() self._pygamecanvas = sugargame.canvas.PygameCanvas( - self, main=self.game.run, modules=[pygame.display, pygame.font] + self, main=self.game.run, modules=[pygame.display, pygame.font, pygame.mixer] ) self.set_canvas(self._pygamecanvas) self._pygamecanvas.grab_focus() diff --git a/main.py b/main.py index 2491c49..a7869a7 100755 --- a/main.py +++ b/main.py @@ -34,6 +34,7 @@ def __init__(self, parent, x, y): self.right = 0 self.down = 0 self.owner = None + self.point_sound = pygame.mixer.Sound('assets/point.ogg') def check(self): return ((self.up + self.left + self.right + self.down) == 4) @@ -47,6 +48,7 @@ def setOwner(self, owner): else: self.owner = 'B' PLAYER_B = PLAYER_B + 1 + self.point_sound.play() self.showOwner() def showOwner(self): @@ -379,6 +381,8 @@ def where(self, pos): def run(self): self.screen = pygame.display.get_surface() + self.click_sound = pygame.mixer.Sound('assets/click.ogg') + self.click_sound.set_volume(0.4) if not self.screen: self.screen = pygame.display.set_mode((900, 700)) pygame.display.set_caption(_('Dots and boxes')) @@ -395,6 +399,7 @@ def run(self): if event.type == pygame.QUIT: run = False elif event.type == pygame.MOUSEBUTTONDOWN: + self.click_sound.play() pos = event.pos ret = self.where(pos) if ret == False: @@ -417,6 +422,7 @@ def run(self): run2 = False self.draw_grid() elif event.type == pygame.MOUSEBUTTONDOWN: + self.click_sound.play() run2 = False self.draw_grid() pygame.display.flip() diff --git a/sounds/click.ogg b/sounds/click.ogg new file mode 100644 index 0000000..1801fc7 Binary files /dev/null and b/sounds/click.ogg differ diff --git a/sounds/point.ogg b/sounds/point.ogg new file mode 100644 index 0000000..c6a9ba9 Binary files /dev/null and b/sounds/point.ogg differ