Add looping gameplay music

This commit is contained in:
2026-05-07 20:03:20 +02:00
parent 5233294b26
commit a908b50019
4 changed files with 92 additions and 0 deletions
+11
View File
@@ -12,6 +12,9 @@ from engine.user_profile_integration import UserProfileIntegration
from runtime_paths import bundle_path
GAMEPLAY_MUSIC = "Clockwork_Thicket.mp3"
class MiceMaze(
controls.KeyBindings,
unit_manager.UnitManager,
@@ -44,6 +47,7 @@ class MiceMaze(
self.render_engine = engine.GameWindow(self.map.width, self.map.height,
self.cell_size, window_title,
key_callback=self.trigger)
self.render_engine.audio = self.audio
# Apply profile settings
if hasattr(self.render_engine, 'set_volume'):
@@ -245,7 +249,14 @@ class MiceMaze(
if random.random() < 0.01:
data["count"] = min(data["count"] + 1, data["max"])
def update_background_music(self):
if self.game_status == "game" and not self.game_end[0]:
self.render_engine.play_music(GAMEPLAY_MUSIC, loop=True)
return
self.render_engine.pause_music()
def update_maze(self):
self.update_background_music()
if self.game_over():
return
if self.game_status == "paused":