From 231c19c7fdbaaf328daa8a5df0a5731babbb75d9 Mon Sep 17 00:00:00 2001 From: Giovani Rodriguez Date: Thu, 10 Jun 2021 20:09:05 +0000 Subject: [PATCH] fix: address issue with nonplaying sound and delay --- Tetris.py | 1 + entity/Piece.py | 2 +- entity/Stack.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Tetris.py b/Tetris.py index 7963bea..002ba42 100644 --- a/Tetris.py +++ b/Tetris.py @@ -95,6 +95,7 @@ class Tetris: self.current_piece.revert() if event.key == pygame.K_z: if self.current_piece: + self.current_piece.play_piece_set_sound() self.stack.add_piece(self.current_piece) self.__generate_piece((300, 100)) diff --git a/entity/Piece.py b/entity/Piece.py index 2706669..0925fde 100644 --- a/entity/Piece.py +++ b/entity/Piece.py @@ -76,7 +76,7 @@ class Piece(Entity): # TODO should be private def play_piece_set_sound(self) -> None: - piece_set_sound_file = ConfigurationManager.configuration["sound"]["rpiece-set"] + piece_set_sound_file = ConfigurationManager.configuration["sound"]["piece-set"] self.piece_set_sound.play(mixer.Sound(piece_set_sound_file)) def __get_points(self, shape: Tuple, position: Tuple) -> List: diff --git a/entity/Stack.py b/entity/Stack.py index 9bd70d8..fca3217 100644 --- a/entity/Stack.py +++ b/entity/Stack.py @@ -38,6 +38,8 @@ class Stack(Entity): if len(squares_to_exclude) == 0: return 0 + self.__play_row_completion_sound() + tile_size = ConfigurationManager.configuration["engine"]["tile-size"] new_points = [] for square in self.points: @@ -51,7 +53,6 @@ class Stack(Entity): new_points.append(square) self.points = new_points - self.__play_row_completion_sound() return len(rows_completed) def __play_row_completion_sound(self) -> None: