Pause and resume sounds when pausing game
This commit is contained in:
+1
-1
@@ -190,7 +190,7 @@ gameOverMenu u =
|
||||
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
|
||||
|
||||
unpause :: Universe -> Universe
|
||||
unpause = over uvWorld resumeSound . set uvScreenLayers []
|
||||
unpause = resumeSound . set uvScreenLayers []
|
||||
|
||||
-- note that this won't update after it is first loaded
|
||||
displayConfig :: Universe -> ScreenLayer
|
||||
|
||||
+12
-6
@@ -27,23 +27,29 @@ import Control.Lens
|
||||
import Data.Int (Int16)
|
||||
import qualified Data.Map as M
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.SoundLogic.LoadSound
|
||||
import Geometry.Data
|
||||
import Geometry.Vector
|
||||
import Sound.Data
|
||||
import SDL.Mixer as Mix
|
||||
|
||||
-- | Placeholder...
|
||||
haltSound :: World -> World
|
||||
haltSound w = w
|
||||
haltSound = id
|
||||
|
||||
-- | Placeholder...
|
||||
pauseSound :: World -> World
|
||||
pauseSound w = w
|
||||
pauseSound :: Universe -> Universe
|
||||
pauseSound = uvIOEffects %~ \f u -> do
|
||||
Mix.pause (-1)
|
||||
f u
|
||||
|
||||
-- | Placeholder...
|
||||
resumeSound :: World -> World
|
||||
resumeSound w = w
|
||||
resumeSound :: Universe -> Universe
|
||||
resumeSound = uvIOEffects %~ \f u -> do
|
||||
Mix.resume (-1)
|
||||
f u
|
||||
|
||||
|
||||
soundWithStatusVolume ::
|
||||
-- | Volume factor, 0 - 1
|
||||
|
||||
@@ -13,9 +13,15 @@ loadSound (i,s) = do
|
||||
chnk <- Mix.load $ "./data/sound/" ++ s
|
||||
return (i,chnk)
|
||||
|
||||
-- current thinking is to use group 0 for game sounds, group 1 for menu sounds
|
||||
loadSounds :: IO (IM.IntMap Mix.Chunk)
|
||||
loadSounds = do
|
||||
Mix.openAudio Mix.defaultAudio 128
|
||||
Mix.setChannels 32
|
||||
x <- Mix.groupSpan 0 0 29
|
||||
putStrLn $ show x <> " channels assigned to group 0"
|
||||
y <- Mix.groupSpan 1 30 31
|
||||
putStrLn $ show y <> " channels assigned to group 1"
|
||||
fmap IM.fromList $ mapM loadSound $ zip [0..] soundPathList
|
||||
|
||||
loadMusic :: IO (IM.IntMap Mix.Music)
|
||||
|
||||
@@ -500,6 +500,7 @@ updateEnterRegex w = case w ^? hud . hudElement . subInventory of
|
||||
|
||||
pauseGame :: Universe -> Universe
|
||||
pauseGame u = u & uvScreenLayers .~ [pauseMenu u]
|
||||
& pauseSound
|
||||
|
||||
spaceAction :: World -> World
|
||||
spaceAction w = case w ^. hud . hudElement of
|
||||
|
||||
Reference in New Issue
Block a user