Add more positional sound
This commit is contained in:
@@ -35,8 +35,11 @@ updateLamp :: Int -> CRUpdate
|
||||
updateLamp i = unrandUpdate handleLS internalUpdate
|
||||
where
|
||||
handleLS cr w
|
||||
| _crHP cr < 0 = explosionFlashAt (_crPos cr) $ mkSoundBreakGlass w & lightSources %~ IM.delete i
|
||||
| otherwise = w & lightSources . ix i . lsPos .~ _crPos cr
|
||||
| _crHP cr < 0 = explosionFlashAt cPos
|
||||
$ mkSoundBreakGlass cPos w & lightSources %~ IM.delete i
|
||||
| otherwise = w & lightSources . ix i . lsPos .~ cPos
|
||||
where
|
||||
cPos = _crPos cr
|
||||
internalUpdate cr
|
||||
| _crHP cr < 0 = Nothing
|
||||
| otherwise = Just $ doDamage cr
|
||||
|
||||
@@ -42,11 +42,10 @@ killBlock bl w = f bl .
|
||||
where
|
||||
f bl@(Block {_blDegrades = (x:xs)}) = degradeBlock bl . hitSound bl
|
||||
f bl = hitSound' bl
|
||||
hitSound bl | _wlIsSeeThrough bl = mkSoundBreakGlass
|
||||
-- hitSound bl | _wlIsSeeThrough bl = soundMultiFrom sos (soundid+8) 25 0
|
||||
pos = _wlLine bl !! 0
|
||||
hitSound bl | _wlIsSeeThrough bl = mkSoundBreakGlass pos
|
||||
| otherwise = soundMultiFrom sos soundid 25 0
|
||||
hitSound' bl | _wlIsSeeThrough bl = mkSoundSplinterGlass
|
||||
-- hitSound' bl | _wlIsSeeThrough bl = soundMultiFrom sos (soundid+4) 25 0
|
||||
hitSound' bl | _wlIsSeeThrough bl = mkSoundSplinterGlass pos
|
||||
| otherwise = soundMultiFrom sos soundid 25 0
|
||||
sos = [BlockDegradeSound 0,BlockDegradeSound 1]
|
||||
(soundid,_) = randomR (29,32) $ _randGen w
|
||||
|
||||
@@ -65,6 +65,7 @@ resumeSound :: World -> World
|
||||
resumeSound w = w
|
||||
|
||||
{-| Add a sound to the queue for playback.
|
||||
Consider replacing with 'soundOncePos'.
|
||||
-}
|
||||
soundOnce :: Int -> World -> World
|
||||
soundOnce i = over soundQueue ((:) (i,0))
|
||||
@@ -83,17 +84,19 @@ For each origin only one sound will play at a time.
|
||||
soundOnceOrigin
|
||||
:: Int -- ^ ID of the sound to be played
|
||||
-> SoundOrigin -- ^ The \"creator\" of the sound
|
||||
-> Point2 -- ^ The position of the sound in the world
|
||||
-> World -> World
|
||||
soundOnceOrigin sType so = over sounds (M.insertWith (flip const) so sound)
|
||||
soundOnceOrigin sType so p w = over sounds (M.insertWith (flip const) so theSound) w
|
||||
where
|
||||
sound = Sound
|
||||
theSound = Sound
|
||||
{ _soundChunkID = sType
|
||||
, _soundTime = Nothing
|
||||
, _soundFadeTime = 0
|
||||
, _soundStatus = ToStart
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
, _soundPos = Just (a,0)
|
||||
}
|
||||
a = soundAngle p w
|
||||
|
||||
soundFromPos
|
||||
:: SoundOrigin -- ^ \"Creator\" of sound
|
||||
@@ -150,6 +153,7 @@ soundFrom so sType time fadeTime w = over sounds (M.insertWith f so sound) w
|
||||
|
||||
{-| Uses the first free origin from a list.
|
||||
Does nothing if all origins are already creating sounds.
|
||||
TODO: add positional information.
|
||||
-}
|
||||
soundMultiFrom
|
||||
:: [SoundOrigin]
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
module Dodge.WorldEvent.Sound
|
||||
where
|
||||
import Dodge.Data
|
||||
import Geometry.Data (Point2)
|
||||
|
||||
import Dodge.SoundLogic
|
||||
import System.Random
|
||||
|
||||
import Control.Lens
|
||||
|
||||
mkSoundBreakGlass :: World -> World
|
||||
mkSoundBreakGlass w = soundOnceOrigin soundid (GlassBreakSound 0) $ set randGen g w
|
||||
mkSoundBreakGlass :: Point2 -> World -> World
|
||||
mkSoundBreakGlass p w = soundOnceOrigin soundid (GlassBreakSound 0) p $ set randGen g w
|
||||
where
|
||||
(soundid,g) = _randGen w & randomR (37,40)
|
||||
|
||||
mkSoundSplinterGlass :: World -> World
|
||||
mkSoundSplinterGlass w = soundOnceOrigin soundid (GlassBreakSound 1) $ set randGen g w
|
||||
mkSoundSplinterGlass :: Point2 -> World -> World
|
||||
mkSoundSplinterGlass p w = soundOnceOrigin soundid (GlassBreakSound 1) p $ set randGen g w
|
||||
where
|
||||
(soundid,g) = _randGen w & randomR (33,36)
|
||||
|
||||
Reference in New Issue
Block a user