Remove loop dependency on loading dodge sounds
This commit is contained in:
+20
-24
@@ -1,12 +1,7 @@
|
||||
module Dodge.SoundLogic where
|
||||
-- imports {{{
|
||||
import Dodge.Data
|
||||
|
||||
import Control.Lens
|
||||
import qualified Data.Map as M
|
||||
-- }}}
|
||||
--
|
||||
-- PLACEHOLDERS:
|
||||
|
||||
haltSound :: World -> World
|
||||
haltSound w = w
|
||||
@@ -21,26 +16,28 @@ soundOnce :: Int -> World -> World
|
||||
soundOnce i = over soundQueue ((:) i)
|
||||
|
||||
continueSoundFrom :: SoundOrigin -> Int -> Int -> Int -> World -> World
|
||||
continueSoundFrom so sType time fadeTime w
|
||||
= over sounds (M.insertWith f so sound) w
|
||||
where sound = Sound { _soundType = sType
|
||||
, _soundTime = time
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
}
|
||||
f _ s = s {_soundTime = time, _soundFadeTime = fadeTime}
|
||||
continueSoundFrom so sType time fadeTime w = over sounds (M.insertWith f so sound) w
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundType = sType
|
||||
, _soundTime = time
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
}
|
||||
f _ s = s {_soundTime = time, _soundFadeTime = fadeTime}
|
||||
|
||||
soundFrom :: SoundOrigin -> Int -> Int -> Int -> World -> World
|
||||
soundFrom so sType time fadeTime w
|
||||
= over sounds (M.insertWith f so sound) w
|
||||
where sound = Sound { _soundType = sType
|
||||
, _soundTime = time
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
}
|
||||
f _ s = s {_soundTime = time, _soundFadeTime = fadeTime}
|
||||
soundFrom so sType time fadeTime w = over sounds (M.insertWith f so sound) w
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundType = sType
|
||||
, _soundTime = time
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
}
|
||||
f _ s = s {_soundTime = time, _soundFadeTime = fadeTime}
|
||||
|
||||
soundMultiFrom :: [SoundOrigin] -> Int -> Int -> Int -> World -> World
|
||||
soundMultiFrom [] _ _ _ w = w
|
||||
@@ -57,7 +54,6 @@ soundMultiFrom (so:sos) sType time fadeTime w
|
||||
stopSoundFrom :: SoundOrigin -> World -> World
|
||||
stopSoundFrom so = over (sounds . ix so . soundTime) (min 0)
|
||||
|
||||
|
||||
-- idea: pass the id of the sound to the world and send it to some queue for
|
||||
-- playback
|
||||
|
||||
|
||||
Reference in New Issue
Block a user