Add sound source files
This commit is contained in:
@@ -64,7 +64,6 @@ data World = World
|
||||
, _pressPlates :: IM.IntMap PressPlate
|
||||
, _buttons :: IM.IntMap Button
|
||||
, _soundQueue :: [Int]
|
||||
-- , _loadedSounds :: IM.IntMap Mix.Chunk
|
||||
, _sounds :: M.Map SoundOrigin Sound
|
||||
, _decorations :: IM.IntMap Drawing
|
||||
, _corpses :: IM.IntMap (IM.IntMap [Corpse])
|
||||
|
||||
+8
-21
@@ -111,27 +111,14 @@ loadSounds = do
|
||||
-- -- fmap (set soundQueue creatureSounds) $ return w
|
||||
-- where creatureSounds = []
|
||||
|
||||
--playSounds :: a -> World -> IO ()
|
||||
--playSounds _ w = do
|
||||
-- forM_ (_soundQueue w) (\n -> Mix.playOn (-1) 0 (_loadedSounds w IM.! n))
|
||||
-- -- = return $ set soundQueue creatureSounds w
|
||||
-- -- = do forM_ (_soundQueue w) (\n -> Mix.playOn (-1) (_loadedSounds w IM.! n) 0)
|
||||
-- -- fmap (set soundQueue creatureSounds) $ return w
|
||||
-- where creatureSounds = []
|
||||
|
||||
soundOnce :: Int -> World -> World
|
||||
soundOnce i = over soundQueue ((:) i)
|
||||
|
||||
--stepSoundTimers :: World -> IO World
|
||||
--stepSoundTimers w = M.foldrWithKey stepSoundTimer (return w) (_sounds w)
|
||||
|
||||
-- ok, this is hard to reason about-- bugs can occur because I am unsure when
|
||||
-- everything is evaluated
|
||||
--stepSoundTimer :: SoundOrigin -> Sound -> IO World -> IO World
|
||||
--stepSoundTimer so s w =
|
||||
-- case _soundChannel s of
|
||||
-- Nothing -> do w1 <- w
|
||||
-- let soundChunk = _loadedSounds w1 IM.! _soundType s
|
||||
---- n <- Mix.playingCount
|
||||
-- channel <- Mix.playOn (-1) (-1) soundChunk
|
||||
-- -- w2 <- w -- Note that using w2 instead of w1 in the
|
||||
-- -- final return breaks the sound sometimes, must be
|
||||
-- -- something to do with order of evaluation
|
||||
-- return $ set (sounds . ix so . soundChannel) (Just $ fromIntegral channel) w1
|
||||
-- Just channel -> case _soundTime s of
|
||||
-- x | x > 0 -> fmap (set (sounds . ix so . soundTime) (x-1)) w
|
||||
-- | x <= 0 -> do Mix.fadeOut channel (fromIntegral $ _soundFadeTime s+ 1)
|
||||
-- fmap (over sounds (M.delete so)) w
|
||||
-- the sound fade doesn't seem to like being 0
|
||||
|
||||
@@ -61,6 +61,30 @@ update w
|
||||
where (x,y) = zoneOfPoint $ _clPos cr
|
||||
cid = _clID cr
|
||||
|
||||
--updateSound :: World -> World
|
||||
--updateSound = set soundQueue [] . stepSoundTimers
|
||||
--stepSoundTimers :: World -> IO World
|
||||
--stepSoundTimers w = M.foldrWithKey stepSoundTimer (return w) (_sounds w)
|
||||
|
||||
---- ok, this is hard to reason about-- bugs can occur because I am unsure when
|
||||
---- everything is evaluated
|
||||
--stepSoundTimer :: SoundOrigin -> Sound -> IO World -> IO World
|
||||
--stepSoundTimer so s w =
|
||||
-- case _soundChannel s of
|
||||
-- Nothing -> do w1 <- w
|
||||
-- let soundChunk = _loadedSounds w1 IM.! _soundType s
|
||||
---- n <- Mix.playingCount
|
||||
-- channel <- Mix.playOn (-1) (-1) soundChunk
|
||||
-- -- w2 <- w -- Note that using w2 instead of w1 in the
|
||||
-- -- final return breaks the sound sometimes, must be
|
||||
-- -- something to do with order of evaluation
|
||||
-- return $ set (sounds . ix so . soundChannel) (Just $ fromIntegral channel) w1
|
||||
-- Just channel -> case _soundTime s of
|
||||
-- x | x > 0 -> fmap (set (sounds . ix so . soundTime) (x-1)) w
|
||||
-- | x <= 0 -> do Mix.fadeOut channel (fromIntegral $ _soundFadeTime s+ 1)
|
||||
-- fmap (over sounds (M.delete so)) w
|
||||
---- the sound fade doesn't seem to like being 0
|
||||
|
||||
updateLightSources w = set tempLightSources (catMaybes tlss) w'
|
||||
where (w',tlss) = mapAccumR (\a b -> _tlsUpdate b a b) w $ _tempLightSources w
|
||||
|
||||
|
||||
Reference in New Issue
Block a user