fix: address issue with nonplaying sound and delay
This commit is contained in:
@@ -95,6 +95,7 @@ class Tetris:
|
|||||||
self.current_piece.revert()
|
self.current_piece.revert()
|
||||||
if event.key == pygame.K_z:
|
if event.key == pygame.K_z:
|
||||||
if self.current_piece:
|
if self.current_piece:
|
||||||
|
self.current_piece.play_piece_set_sound()
|
||||||
self.stack.add_piece(self.current_piece)
|
self.stack.add_piece(self.current_piece)
|
||||||
self.__generate_piece((300, 100))
|
self.__generate_piece((300, 100))
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Piece(Entity):
|
|||||||
|
|
||||||
# TODO should be private
|
# TODO should be private
|
||||||
def play_piece_set_sound(self) -> None:
|
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))
|
self.piece_set_sound.play(mixer.Sound(piece_set_sound_file))
|
||||||
|
|
||||||
def __get_points(self, shape: Tuple, position: Tuple) -> List:
|
def __get_points(self, shape: Tuple, position: Tuple) -> List:
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class Stack(Entity):
|
|||||||
if len(squares_to_exclude) == 0:
|
if len(squares_to_exclude) == 0:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
self.__play_row_completion_sound()
|
||||||
|
|
||||||
tile_size = ConfigurationManager.configuration["engine"]["tile-size"]
|
tile_size = ConfigurationManager.configuration["engine"]["tile-size"]
|
||||||
new_points = []
|
new_points = []
|
||||||
for square in self.points:
|
for square in self.points:
|
||||||
@@ -51,7 +53,6 @@ class Stack(Entity):
|
|||||||
new_points.append(square)
|
new_points.append(square)
|
||||||
self.points = new_points
|
self.points = new_points
|
||||||
|
|
||||||
self.__play_row_completion_sound()
|
|
||||||
return len(rows_completed)
|
return len(rows_completed)
|
||||||
|
|
||||||
def __play_row_completion_sound(self) -> None:
|
def __play_row_completion_sound(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user