feat: add the rest of the sounds with channels
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from typing import List, Tuple
|
||||
from pygame import mixer
|
||||
import copy
|
||||
|
||||
from entity.Entity import Entity
|
||||
@@ -15,6 +16,7 @@ class Piece(Entity):
|
||||
def __init__(self, shape: Tuple, position: Tuple, color: str, border_color: str):
|
||||
super().__init__(self.__get_points(shape, position), color, border_color)
|
||||
self.center = self.__get_center(shape, position)
|
||||
self.piece_set_sound = mixer.Channel(2)
|
||||
|
||||
self.previous_points = None
|
||||
self.previous_center = None
|
||||
@@ -72,6 +74,11 @@ class Piece(Entity):
|
||||
self.points = self.previous_points
|
||||
self.center = self.previous_center
|
||||
|
||||
# TODO should be private
|
||||
def play_piece_set_sound(self) -> None:
|
||||
piece_set_sound_file = ConfigurationManager.configuration["sound"]["rpiece-set"]
|
||||
self.piece_set_sound.play(mixer.Sound(piece_set_sound_file))
|
||||
|
||||
def __get_points(self, shape: Tuple, position: Tuple) -> List:
|
||||
tile_size = ConfigurationManager.configuration["engine"]["tile-size"]
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from pygame import mixer
|
||||
|
||||
from util.ConfigurationManager import ConfigurationManager
|
||||
from entity.Piece import Piece
|
||||
from entity.Well import Well
|
||||
@@ -8,6 +10,7 @@ class Stack(Entity):
|
||||
def __init__(self, color: str, border_color: str):
|
||||
super().__init__([], color, border_color)
|
||||
self.rows_completed_count = 0
|
||||
self.row_completion_sound = mixer.Channel(1)
|
||||
|
||||
def update(self, elapsed_time) -> None:
|
||||
super().update(elapsed_time)
|
||||
@@ -48,4 +51,9 @@ class Stack(Entity):
|
||||
new_points.append(square)
|
||||
self.points = new_points
|
||||
|
||||
return len(rows_completed)
|
||||
self.__play_row_completion_sound()
|
||||
return len(rows_completed)
|
||||
|
||||
def __play_row_completion_sound(self) -> None:
|
||||
row_completion_sound_file = ConfigurationManager.configuration["sound"]["row-completion"]
|
||||
self.row_completion_sound.play(mixer.Sound(row_completion_sound_file))
|
||||
Reference in New Issue
Block a user