Add support for directional sound
This commit is contained in:
+9
-1
@@ -63,7 +63,9 @@ updateSounds sd ss = do
|
||||
|
||||
updateSound :: IM.IntMap Mix.Chunk -> Sound -> MaybeT IO Sound
|
||||
updateSound sd s =
|
||||
initialisePlaying sd s >>= liftIO . decrementTimer >>= cleanupHalted
|
||||
initialisePlaying sd s
|
||||
>>= liftIO . (decrementTimer >=> applyPosition)
|
||||
>>= cleanupHalted
|
||||
|
||||
initialisePlaying :: IM.IntMap Mix.Chunk -> Sound -> MaybeT IO Sound
|
||||
initialisePlaying sd s = case _soundStatus s of
|
||||
@@ -98,6 +100,12 @@ decrementTimer s = case _soundTime s of
|
||||
& soundStatus .~ FadingOut)
|
||||
Nothing -> return s
|
||||
|
||||
applyPosition :: Sound -> IO Sound
|
||||
applyPosition s = case _soundPos s of
|
||||
Nothing -> return s
|
||||
Just (a,d) -> Mix.effectPosition (fromJust $ _soundChannel s) a d
|
||||
>> return (s & soundPos .~ Nothing)
|
||||
|
||||
fadeOutMaybe :: Maybe Mix.Channel -> Int -> IO ()
|
||||
fadeOutMaybe (Just x) fadeT = Mix.fadeOut (fromIntegral fadeT + 1) x
|
||||
fadeOutMaybe _ _ = return ()
|
||||
|
||||
Reference in New Issue
Block a user