Pause and resume sounds when pausing game

This commit is contained in:
2025-06-02 12:43:37 +01:00
parent 6706ac494a
commit 1851dcc5d6
8 changed files with 74 additions and 63 deletions
+2 -2
View File
@@ -96,7 +96,7 @@ tryPlay sd s = do
tryGetChannel :: Sound -> MaybeT IO Mix.Channel
tryGetChannel s = case _soundChannel s of
Just i -> return i
Nothing -> MaybeT $ Mix.getAvailable Mix.DefaultGroup
Nothing -> MaybeT $ Mix.getAvailable 0 -- 0 refers to the group for game sounds
decrementTimer :: Sound -> IO Sound
decrementTimer s = case _soundTime s of
@@ -135,7 +135,7 @@ playSoundQueue chunkMap = mapM_ $ \n -> runMaybeT $ playIfFree (chunkMap IM.! n)
times. Returns 'Just' the channel if succeeds. -}
playIfFree :: Mix.Chunk -> Mix.Times -> MaybeT IO Mix.Channel
playIfFree c times = do
i <- MaybeT $ Mix.getAvailable Mix.DefaultGroup
i <- MaybeT $ Mix.getAvailable 0 -- 0 refers to the group for game sounds
liftIO $ Mix.playOn i times c
-----------------------------------------------------------------