feat(game): add langing sound

This commit is contained in:
Kristofers Solo 2024-01-04 06:43:34 +02:00
parent 91587b772f
commit 7f9b1fb266
4 changed files with 6 additions and 2 deletions

BIN
assets/music/landing.wav Normal file

Binary file not shown.

View File

@ -49,6 +49,9 @@ class Game:
self.score = 0 self.score = 0
self.lines = 0 self.lines = 0
self.landing_sound = pygame.mixer.Sound(CONFIG.music.landing)
self.landing_sound.set_volume(CONFIG.music.volume)
def run(self) -> None: def run(self) -> None:
self.dispaly_surface.blit(self.surface, CONFIG.game.pos) self.dispaly_surface.blit(self.surface, CONFIG.game.pos)
self.draw() self.draw()
@ -110,6 +113,7 @@ class Game:
self.tetromino.move_horizontal(Direction.RIGHT) self.tetromino.move_horizontal(Direction.RIGHT)
def create_new_tetromino(self) -> None: def create_new_tetromino(self) -> None:
self.landing_sound.play()
if self.game_over(): if self.game_over():
self.restart() self.restart()

View File

@ -26,7 +26,7 @@ class Main:
self.music = pygame.mixer.Sound(CONFIG.music.background) self.music = pygame.mixer.Sound(CONFIG.music.background)
self.music.set_volume(CONFIG.music.volume) self.music.set_volume(CONFIG.music.volume)
self.music.play() self.music.play(-1)
def draw(self) -> None: def draw(self) -> None:
pygame.display.update() pygame.display.update()

View File

@ -54,7 +54,7 @@ class Window:
@define @define
class Music: class Music:
background: Path = BASE_PATH / "assets" / "music" / "background.wav" background: Path = BASE_PATH / "assets" / "music" / "background.wav"
langing: Path = BASE_PATH / "assets" / "music" / "landing.wav" landing: Path = BASE_PATH / "assets" / "music" / "landing.wav"
volume: float = 0.01 volume: float = 0.01