Refactor sound

This commit is contained in:
2021-09-12 17:52:34 +01:00
parent ea333a363b
commit 51a85bd1ec
97 changed files with 409 additions and 177 deletions
Binary file not shown.
Binary file not shown.
+4 -4
View File
@@ -19,7 +19,7 @@ import Dodge.Base
import Dodge.Zone import Dodge.Zone
import Dodge.Base.Collide import Dodge.Base.Collide
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
--import Dodge.WorldEvent --import Dodge.WorldEvent
import Dodge.Inventory import Dodge.Inventory
--import Dodge.LightSources --import Dodge.LightSources
@@ -167,7 +167,7 @@ blinkAction
-> World -> World
-> World -> World
blinkAction cr w blinkAction cr w
= soundMultiFrom [TeleSound 0,TeleSound 1] p3 teleSound Nothing = soundMultiFrom [TeleSound 0,TeleSound 1] p3 teleS Nothing
. over radDistortion (distortionBulge ++) . over radDistortion (distortionBulge ++)
. set (creatures . ix cid . crPos) p3 . set (creatures . ix cid . crPos) p3
. blinkShockwave cid p3 . blinkShockwave cid p3
@@ -198,7 +198,7 @@ youDropItem w = case yourItem w of
NoItem -> w NoItem -> w
_ -> rmSelectedInvItem (_yourID w) _ -> rmSelectedInvItem (_yourID w)
. copyItemToFloor (you w) (_crInvSel cr) . copyItemToFloor (you w) (_crInvSel cr)
$ soundFrom (CrSound (_crID cr)) (_crPos cr) putDownSound Nothing $ soundFrom (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing
w w
where where
cr = you w cr = you w
@@ -233,7 +233,7 @@ pickUpItem
pickUpItem cid flit w = case maybeInvSlot of pickUpItem cid flit w = case maybeInvSlot of
Nothing -> w Nothing -> w
Just i -> w Just i -> w
& soundFrom (CrSound cid) (_flItPos flit) pickUpSound Nothing & soundFrom (CrSound cid) (_flItPos flit) pickUpS Nothing
& updateItLocation i & updateItLocation i
& floorItems %~ IM.delete (_flItID flit) & floorItems %~ IM.delete (_flItID flit)
& creatures . ix cid . crInv . ix i %~ addItem it & creatures . ix cid . crInv . ix i %~ addItem it
+2 -2
View File
@@ -11,7 +11,7 @@ import Dodge.Data.DamageType
import Dodge.Creature.State.Data import Dodge.Creature.State.Data
import Dodge.Creature.Stance.Data import Dodge.Creature.Stance.Data
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Geometry import Geometry
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
@@ -84,5 +84,5 @@ followImpulse cr w imp = case imp of
posFromID cid' = _crPos $ _creatures w IM.! cid' posFromID cid' = _crPos $ _creatures w IM.! cid'
rr a = fst $ randomR (-a,a) $ _randGen w rr a = fst $ randomR (-a,a) $ _randGen w
hitCr i = over (creatures . ix i . crState . crDamage) (addDam i) hitCr i = over (creatures . ix i . crState . crDamage) (addDam i)
. soundFrom (CrSound cid) cpos hitSound Nothing . soundFrom (CrSound cid) cpos hitS Nothing
addDam i dams = Blunt 100 cpos (posFromID i) (posFromID i) : dams addDam i dams = Blunt 100 cpos (posFromID i) (posFromID i) : dams
+3 -3
View File
@@ -9,7 +9,7 @@ import Dodge.Creature.Stance.Data
--import Dodge.Creature.Test --import Dodge.Creature.Test
--import Dodge.Base --import Dodge.Base
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Dodge.RandomHelp import Dodge.RandomHelp
import Dodge.WorldEvent import Dodge.WorldEvent
--import Dodge.WallCreatureCollisions --import Dodge.WallCreatureCollisions
@@ -141,7 +141,7 @@ weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of
| otherwise -> w | otherwise -> w
Just Weapon{_wpReloadState = 0} -> w Just Weapon{_wpReloadState = 0} -> w
Just Weapon{_wpReloadState = 1} -> stopSoundFrom (CrReloadSound cid) w Just Weapon{_wpReloadState = 1} -> stopSoundFrom (CrReloadSound cid) w
Just Weapon{} -> soundFrom (CrReloadSound cid) (_crPos cr) reloadSound (Just 1) w Just Weapon{} -> soundFrom (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
_ -> w _ -> w
where where
cid = _crID cr cid = _crID cr
@@ -223,7 +223,7 @@ updateExpBarrel cr w
applyFuseDamage cr' = cr' & crHP %~ applyFuseDamage cr' = cr' & crHP %~
subtract (length . _piercedPoints . _crSpState $ _crState cr') subtract (length . _piercedPoints . _crSpState $ _crState cr')
hiss | null poss = id hiss | null poss = id
| otherwise = soundMultiFrom [BarrelHiss 0,BarrelHiss 1] (_crPos cr) 41 (Just 1) | otherwise = soundMultiFrom [BarrelHiss 0,BarrelHiss 1] (_crPos cr) foamSprayLoopS (Just 1)
stopSounds = stopSoundFrom (BarrelHiss 0) . stopSoundFrom (BarrelHiss 1) stopSounds = stopSoundFrom (BarrelHiss 0) . stopSoundFrom (BarrelHiss 1)
damToExpBarrel :: [DamageType] -> Creature -> Creature damToExpBarrel :: [DamageType] -> Creature -> Creature
+5 -3
View File
@@ -4,7 +4,9 @@ import Dodge.Data
import Dodge.Data.SoundOrigin import Dodge.Data.SoundOrigin
import Dodge.Creature.Stance.Data import Dodge.Creature.Stance.Data
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.LoadSound
import Geometry.Data import Geometry.Data
import Sound.Data
import Control.Lens import Control.Lens
@@ -36,6 +38,6 @@ makeFootstepSound currentStride maxStride ff p
where where
footor = [FootstepSound 0,FootstepSound 1] footor = [FootstepSound 0,FootstepSound 1]
chooseFootSound :: FootForward -> Int chooseFootSound :: FootForward -> SoundID
chooseFootSound LeftForward = 22 chooseFootSound LeftForward = foot1S
chooseFootSound _ = 23 chooseFootSound _ = foot2S
+3 -3
View File
@@ -5,12 +5,12 @@ import Dodge.Data
import Dodge.Base.Collide import Dodge.Base.Collide
import Dodge.Creature.Test import Dodge.Creature.Test
import Dodge.Creature.Stance.Data import Dodge.Creature.Stance.Data
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Geometry import Geometry
holsterWeapon, drawWeapon :: Action holsterWeapon, drawWeapon :: Action
holsterWeapon = DoImpulses [ChangePosture AtEase, MakeSound putDownSound] holsterWeapon = DoImpulses [ChangePosture AtEase, MakeSound whiteNoiseFadeOutS]
drawWeapon = DoImpulses [ChangePosture Aiming, MakeSound pickUpSound] drawWeapon = DoImpulses [ChangePosture Aiming, MakeSound whiteNoiseFadeInS]
fleeFrom :: Creature -> Maybe Creature -> Action fleeFrom :: Creature -> Maybe Creature -> Action
fleeFrom cr mtcr = case mtcr of fleeFrom cr mtcr = case mtcr of
+2 -2
View File
@@ -378,7 +378,7 @@ data Item
} }
| NoItem | NoItem
data ReloadType = ActiveReload | PassiveReload Int data ReloadType = ActiveReload | PassiveReload SoundID
data ItEffect = NoItEffect data ItEffect = NoItEffect
| ItInvEffect | ItInvEffect
@@ -581,7 +581,7 @@ data Impulse
-- | UseIntrinsicAbility -- | UseIntrinsicAbility
| Melee Int | Melee Int
| ChangePosture Posture | ChangePosture Posture
| MakeSound Int | MakeSound SoundID
| ChangeStrategy Strategy | ChangeStrategy Strategy
| AddGoal Goal | AddGoal Goal
| ArbitraryImpulseFunction (World -> Creature -> Creature) | ArbitraryImpulseFunction (World -> Creature -> Creature)
+2 -1
View File
@@ -15,6 +15,7 @@ import Dodge.Creature.State.Data
import Dodge.Creature.Perception.Data import Dodge.Creature.Perception.Data
import Dodge.Creature.Memory.Data import Dodge.Creature.Memory.Data
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.LoadSound
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Geometry import Geometry
import Picture import Picture
@@ -214,7 +215,7 @@ defaultButton = Button
, _btEvent = \b w -> , _btEvent = \b w ->
set (buttons . ix (_btID b) . btPict) (onLayer WlLayer $ color red $ polygon $ rectNSEW (-4) (-5) 10 (-10)) set (buttons . ix (_btID b) . btPict) (onLayer WlLayer $ color red $ polygon $ rectNSEW (-4) (-5) 10 (-10))
. set (buttons . ix (_btID b) . btState) BtNoLabel . set (buttons . ix (_btID b) . btState) BtNoLabel
. soundFrom (LeverSound 0) (_btPos b) 1 Nothing $ w . soundFrom (LeverSound 0) (_btPos b) click1S Nothing $ w
, _btID = 0 , _btID = 0
, _btText = "Button" , _btText = "Button"
, _btState = BtOff , _btState = BtOff
+2 -2
View File
@@ -9,7 +9,7 @@ import Dodge.Layout
import Dodge.Story import Dodge.Story
import Dodge.WorldEvent.Cloud import Dodge.WorldEvent.Cloud
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
--import Dodge.Creature.Perception --import Dodge.Creature.Perception
import Geometry.Data import Geometry.Data
--import Picture --import Picture
@@ -47,7 +47,7 @@ initialWorld = defaultWorld
, _mousePos = V2 0 0 , _mousePos = V2 0 0
, _testString = testStringInit , _testString = testStringInit
, _yourID = 0 , _yourID = 0
, _worldEvents = soundFrom BackgroundSound (V2 0 0) foamSprayFadeOutSound Nothing , _worldEvents = soundFrom BackgroundSound (V2 0 0) foamSprayFadeOutS Nothing
. foldr ((.) . makeStartCloudAt) id [V3 x y 5 | x <- [-5,-3..5] , y <- [-5,-3..5]] . foldr ((.) . makeStartCloudAt) id [V3 x y 5 | x <- [-5,-3..5] , y <- [-5,-3..5]]
, _pressPlates = IM.empty , _pressPlates = IM.empty
, _buttons = IM.empty , _buttons = IM.empty
+2 -2
View File
@@ -6,7 +6,7 @@ import Dodge.Item.Data
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Dodge.Default import Dodge.Default
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Dodge.Item.Draw import Dodge.Item.Draw
@@ -32,7 +32,7 @@ heal25 :: Int -> World -> Maybe World
heal25 = heal 25 heal25 = heal 25
heal :: Int -> Int -> World -> Maybe World heal :: Int -> Int -> World -> Maybe World
heal hp n w | _crHP (_creatures w IM.! n) >= 10000 = Nothing heal hp n w | _crHP (_creatures w IM.! n) >= 10000 = Nothing
| otherwise = Just $ soundFrom (CrSound $ _crID cr) (_crPos cr) healSound Nothing w | otherwise = Just $ soundFrom (CrSound $ _crID cr) (_crPos cr) healS Nothing w
& creatures . ix n . crHP %~ min 10000 . (+ hp) & creatures . ix n . crHP %~ min 10000 . (+ hp)
where where
cr = _creatures w IM.! n cr = _creatures w IM.! n
+17 -17
View File
@@ -8,7 +8,7 @@ import Dodge.Base
import Dodge.Zone import Dodge.Zone
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Dodge.Creature.Action import Dodge.Creature.Action
import Dodge.RandomHelp import Dodge.RandomHelp
import Dodge.WorldEvent import Dodge.WorldEvent
@@ -66,7 +66,7 @@ pistol = defaultGun
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheckI , useTimeCheckI
, withSoundI 0 , withSoundI tap3S
, useAmmo 1 , useAmmo 1
, randSpreadDir , randSpreadDir
, withMuzFlareI , withMuzFlareI
@@ -145,7 +145,7 @@ teslaGun = defaultGun
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withTempLight 1 100 (V3 0 0 1) , withTempLight 1 100 (V3 0 0 1)
, withSoundForI 25 1 , withSoundForI elecCrackleS 1
, useAmmo 1 , useAmmo 1
] ]
, _wpSpread = 0.001 , _wpSpread = 0.001
@@ -180,7 +180,7 @@ lasGun = defaultAutoGun
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withTempLight 1 100 (V3 1 1 0) , withTempLight 1 100 (V3 1 1 0)
, withSoundForI 24 1 , withSoundForI tone440sawtoothS 1
, useAmmo 1 , useAmmo 1
] ]
, _wpSpread = 0.001 , _wpSpread = 0.001
@@ -296,7 +296,7 @@ hvAutoGun = defaultAutoGun
, _itUseModifiers = , _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, rateIncABI 24 7 (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2) , rateIncABI 24 7 (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2)
, withSoundI longGunSound , withSoundI bangEchoS
, withThinSmokeI , withThinSmokeI
, withMuzFlareI , withMuzFlareI
] ]
@@ -323,7 +323,7 @@ ltAutoGun = defaultAutoGun
, _itUseModifiers = , _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withSoundI 0 , withSoundI tap1S
, useAmmo 1 , useAmmo 1
, withRandomDirI 0.1 , withRandomDirI 0.1
, torqueAfterI 0.2 , torqueAfterI 0.2
@@ -359,10 +359,10 @@ miniGun = defaultAutoGun
, _itUse = useAmmoParamsVelMod vm4 , _itUse = useAmmoParamsVelMod vm4
, _itUseModifiers = , _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, withWarmUpI 26 , withWarmUpI crankSlowS
, useTimeCheckI , useTimeCheckI
--, afterRecoil recoilAmount --, afterRecoil recoilAmount
, withSoundForI 28 2 , withSoundForI mini1S 2
--, withThinSmokeI --, withThinSmokeI
, torqueAfterI 0.05 , torqueAfterI 0.05
, withSidePushI 53 , withSidePushI 53
@@ -429,7 +429,7 @@ spreadGun = defaultGun
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheckI , useTimeCheckI
, withSoundI shotgunSound , withSoundI shotgunS
, useAmmo 1 , useAmmo 1
, withRecoilI 100 , withRecoilI 100
, withMuzFlareI , withMuzFlareI
@@ -461,7 +461,7 @@ multGun = defaultGun
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheckI , useTimeCheckI
, withSoundI shotgunSound , withSoundI shotgunS
, useAmmo 1 , useAmmo 1
, withRecoilI 200 , withRecoilI 200
, withMuzFlareI , withMuzFlareI
@@ -499,7 +499,7 @@ longGun = defaultGun
, _wpLoadedAmmo = 1 , _wpLoadedAmmo = 1
, _wpReloadTime = 100 , _wpReloadTime = 100
, _wpReloadState = 0 , _wpReloadState = 0
, _wpReloadType = PassiveReload skwareFadeTwoSecSound , _wpReloadType = PassiveReload skwareFadeTwoSecS
, _itUseRate = 100 , _itUseRate = 100
, _itUseTime = 0 , _itUseTime = 0
, _itUse = useAmmoParams , _itUse = useAmmoParams
@@ -507,7 +507,7 @@ longGun = defaultGun
[ ammoCheckI [ ammoCheckI
, hammerCheckI , hammerCheckI
, useTimeCheckI , useTimeCheckI
, withSoundI longGunSound , withSoundI bangEchoS
, useAmmo 1 , useAmmo 1
, withThickSmokeI , withThickSmokeI
, torqueAfterI 0.05 , torqueAfterI 0.05
@@ -553,7 +553,7 @@ poisonSprayer = defaultAutoGun
, _itUseModifiers = , _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withSoundForI foamSpray 5 , withSoundForI foamSprayLoopS 5
, useAmmo 1 , useAmmo 1
, spreadNumI , spreadNumI
] ]
@@ -752,10 +752,10 @@ moveRemoteBomb itid time pID w
$ set (projectiles .ix pID.pjUpdate) (\_ -> moveRemoteBomb itid (f time) pID) $ set (projectiles .ix pID.pjUpdate) (\_ -> moveRemoteBomb itid (f time) pID)
w w
| time < 2 = case hitWl of | time < 2 = case hitWl of
Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing $ halfV updatedWorld Just (p,_) -> soundFrom (Tap 0) p tapQuietS Nothing $ halfV updatedWorld
_ -> halfV updatedWorld _ -> halfV updatedWorld
| otherwise = case hitWl of | otherwise = case hitWl of
Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing updatedWorld Just (p,_) -> soundFrom (Tap 0) p tapQuietS Nothing updatedWorld
_ -> updatedWorld _ -> updatedWorld
where where
updatedWorld updatedWorld
@@ -875,7 +875,7 @@ fireRemoteLauncher :: Creature -> World -> World
fireRemoteLauncher cr w = setLocation fireRemoteLauncher cr w = setLocation
$ resetFire $ resetFire
$ resetName $ resetName
$ soundFrom (CrWeaponSound cid) pos launcherSound Nothing $ soundFrom (CrWeaponSound cid) pos tap4S Nothing
$ over projectiles addRemRocket w $ over projectiles addRemRocket w
where where
i = IM.newKey $ _projectiles w i = IM.newKey $ _projectiles w
@@ -923,7 +923,7 @@ moveRemoteShell cid itid pj w
( ( pjVel %~ ( (accel +.+) . (frict *.*) ) ) ( ( pjVel %~ ( (accel +.+) . (frict *.*) ) )
. ( pjDir .~ newdir ) . ( pjDir .~ newdir )
) )
& soundFrom (ShellSound i) newPos smokeTrailSound (Just 1) & soundFrom (ShellSound i) newPos missileLaunchS (Just 1)
& smokeGen & smokeGen
& makeFlameletTimed oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10 & makeFlameletTimed oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10
| time > -200 = case thingHit of | time > -200 = case thingHit of
+2 -2
View File
@@ -13,7 +13,7 @@ import Dodge.Picture.Layer
import Dodge.Item.Draw import Dodge.Item.Draw
import Dodge.Item.Weapon.Bullet import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.TriggerType
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Picture import Picture
import Geometry import Geometry
@@ -40,7 +40,7 @@ autoGun = defaultAutoGun
[('M', torqueBefore 0.08) [('M', torqueBefore 0.08)
,('S', torqueBefore 0.05) ,('S', torqueBefore 0.05)
] ]
, withSoundI autoGunSound , withSoundForI autoBS 5
, useAmmo 1 , useAmmo 1
, withRandomDirI (autogunSpread/2) , withRandomDirI (autogunSpread/2)
, withMuzFlareI , withMuzFlareI
+2 -1
View File
@@ -15,6 +15,7 @@ import Dodge.Particle.Bullet.HitEffect
import Dodge.WorldEvent.HitEffect import Dodge.WorldEvent.HitEffect
import Dodge.RandomHelp import Dodge.RandomHelp
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Dodge.SoundLogic.LoadSound
import Picture import Picture
import Geometry import Geometry
@@ -28,7 +29,7 @@ bezierGun = defaultGun
, _itUse = \_ -> useTargetPos $ \p -> shootBezier $ fromJust p -- <- the start point , _itUse = \_ -> useTargetPos $ \p -> shootBezier $ fromJust p -- <- the start point
, _itUseModifiers = , _itUseModifiers =
[ useTimeCheckI [ useTimeCheckI
, withSoundI 0 , withSoundI tap2S
, useAmmo 1 , useAmmo 1
, withMuzFlareI , withMuzFlareI
. withRecoilI 40 . withRecoilI 40
+2 -2
View File
@@ -7,7 +7,7 @@ import Dodge.Base
import Dodge.Zone import Dodge.Zone
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Dodge.Item.Attachment.Data import Dodge.Item.Attachment.Data
import Dodge.Item.Draw import Dodge.Item.Draw
import Dodge.Default.Shell import Dodge.Default.Shell
@@ -32,7 +32,7 @@ moveGrenade 0 _ pID w = over projectiles (IM.delete pID)
pj = _projectiles w IM.! pID pj = _projectiles w IM.! pID
explosion = _pjPayload pj explosion = _pjPayload pj
moveGrenade time dir pID w = case hitWl of moveGrenade time dir pID w = case hitWl of
Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing updatedWorld Just (p,_) -> soundFrom (Tap 0) p tapQuietS Nothing updatedWorld
_ -> updatedWorld _ -> updatedWorld
where where
updatedWorld = updateV $ set (projectiles . ix pID . pjPos) finalPos updatedWorld = updateV $ set (projectiles . ix pID . pjPos) finalPos
+3 -3
View File
@@ -4,7 +4,7 @@ import Dodge.Data
import Dodge.Data.SoundOrigin import Dodge.Data.SoundOrigin
import Dodge.Default.Weapon import Dodge.Default.Weapon
import Dodge.Default.Shell import Dodge.Default.Shell
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Dodge.WorldEvent.Explosion import Dodge.WorldEvent.Explosion
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Dodge.Item.Data import Dodge.Item.Data
@@ -43,7 +43,7 @@ launcher = defaultGun
, _itUseModifiers = , _itUseModifiers =
[ ammoCheckI [ ammoCheckI
, useTimeCheckI , useTimeCheckI
, withSoundI launcherSound , withSoundI tap4S
, useAmmo 1 , useAmmo 1
] ]
, _wpSpread = 0.02 , _wpSpread = 0.02
@@ -107,7 +107,7 @@ doThrust :: Projectile -> World -> World
doThrust pj w = w doThrust pj w = w
& randGen .~ g & randGen .~ g
& projectiles . ix i . pjVel %~ (\v -> accel +.+ frict *.* v) & projectiles . ix i . pjVel %~ (\v -> accel +.+ frict *.* v)
& soundFrom (ShellSound i) newPos smokeTrailSound (Just 1) & soundFrom (ShellSound i) newPos missileLaunchS (Just 1)
& makeFlameletTimed (oldPos -.- vel) 0 (vel +.+ rotateV (pi+sparkD) accel) Nothing 3 10 & makeFlameletTimed (oldPos -.- vel) 0 (vel +.+ rotateV (pi+sparkD) accel) Nothing 3 10
& smokeGen & smokeGen
where where
+4 -3
View File
@@ -44,6 +44,7 @@ import Dodge.RandomHelp
import Dodge.Item.Attachment.Data import Dodge.Item.Attachment.Data
import Dodge.Item.Data import Dodge.Item.Data
import Dodge.Default import Dodge.Default
import Sound.Data
import Geometry import Geometry
import Geometry.Vector3D import Geometry.Vector3D
@@ -121,7 +122,7 @@ rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w
&& _itUseTime item == 0 && _itUseTime item == 0
{- | Apply effect after a warm up. -} {- | Apply effect after a warm up. -}
withWarmUpI withWarmUpI
:: Int -- ^ warm up sound id :: SoundID -- ^ warm up sound id
-> ChainEffect -> ChainEffect
withWarmUpI soundID f item cr w withWarmUpI soundID f item cr w
| _wpReloadState item /= 0 = w | _wpReloadState item /= 0 = w
@@ -140,7 +141,7 @@ withWarmUpI soundID f item cr w
{- | Adds a sound to a creature based world effect. {- | Adds a sound to a creature based world effect.
The sound is emitted from the creature's position. -} The sound is emitted from the creature's position. -}
withSoundI withSoundI
:: Int -- ^ Sound id :: SoundID -- ^ Sound id
-> ChainEffect -> ChainEffect
withSoundI soundid f item cr withSoundI soundid f item cr
= soundFrom (CrWeaponSound cid) (_crPos cr) soundid Nothing = soundFrom (CrWeaponSound cid) (_crPos cr) soundid Nothing
@@ -151,7 +152,7 @@ withSoundI soundid f item cr
{- | Adds a sound to a creature based world effect. {- | Adds a sound to a creature based world effect.
The sound is emitted from the creature's position. -} The sound is emitted from the creature's position. -}
withSoundForI withSoundForI
:: Int -- ^ Sound id :: SoundID -- ^ Sound id
-> Int -- ^ Frames to play -> Int -- ^ Frames to play
-> ChainEffect -> ChainEffect
withSoundForI soundid playTime f item cr withSoundForI soundid playTime f item cr
+5 -3
View File
@@ -6,8 +6,10 @@ import Dodge.Base
import Dodge.Zone import Dodge.Zone
import Dodge.Zone.Data import Dodge.Zone.Data
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.LoadSound
import Dodge.WorldEvent.Sound import Dodge.WorldEvent.Sound
import Dodge.LevelGen.Pathing import Dodge.LevelGen.Pathing
import Dodge.RandomHelp
import Geometry import Geometry
import Picture.Data import Picture.Data
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
@@ -46,12 +48,12 @@ killBlock bl w = f bl . flip (foldr unshadow) (_blShadows bl) $ w
pos = fst $ _wlLine bl pos = fst $ _wlLine bl
breakHitSound bl' breakHitSound bl'
| _wlIsSeeThrough bl' = mkSoundBreakGlass pos | _wlIsSeeThrough bl' = mkSoundBreakGlass pos
| otherwise = soundMultiFrom sos (fst $ _wlLine bl') (soundid + 4) Nothing | otherwise = soundMultiFrom sos (fst $ _wlLine bl') impactSound Nothing
hitSound' bl' hitSound' bl'
| _wlIsSeeThrough bl' = mkSoundSplinterGlass pos | _wlIsSeeThrough bl' = mkSoundSplinterGlass pos
| otherwise = soundMultiFrom sos (fst $ _wlLine bl') soundid Nothing | otherwise = soundMultiFrom sos (fst $ _wlLine bl') impactSound Nothing
sos = [BlockDegradeSound 0,BlockDegradeSound 1] sos = [BlockDegradeSound 0,BlockDegradeSound 1]
(soundid,_) = randomR (29,32) $ _randGen w impactSound = evalState (takeOne [impact1S,impact2S,impact3S,impact4S]) $ _randGen w
unshadow :: Int -> World -> World unshadow :: Int -> World -> World
unshadow bid w' = case w' ^? walls . ix bid of unshadow bid w' = case w' ^? walls . ix bid of
Just b -> Just b ->
+2 -2
View File
@@ -11,7 +11,7 @@ import Dodge.Base
import Dodge.Zone import Dodge.Zone
import Dodge.Zone.Data import Dodge.Zone.Data
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Geometry import Geometry
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
@@ -70,7 +70,7 @@ addSoundToDoor i pld hwd (x:ys) = f x : ys
where where
g dm w g dm w
| dist wp pld > 2 && dist wp hwd > 2 | dist wp pld > 2 && dist wp hwd > 2
= soundFrom (WallSound i) wp doorSound (Just 1) $ dm w = soundFrom (WallSound i) wp slideDoorS (Just 1) $ dm w
| otherwise = dm w | otherwise = dm w
where where
wp = fst $ _wlLine (_walls w IM.! i) wp = fst $ _wlLine (_walls w IM.! i)
+3 -2
View File
@@ -3,6 +3,7 @@ module Dodge.LevelGen.Switch
import Dodge.Data import Dodge.Data
import Dodge.Data.SoundOrigin import Dodge.Data.SoundOrigin
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.LoadSound
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Picture import Picture
import Geometry import Geometry
@@ -19,7 +20,7 @@ makeButton c eff = Button
, _btPos = V2 0 0 , _btPos = V2 0 0
, _btRot = 0 , _btRot = 0
, _btEvent = \b w -> eff . over buttons (IM.adjust turnOn (_btID b)) , _btEvent = \b w -> eff . over buttons (IM.adjust turnOn (_btID b))
. soundFromGeneral (LeverSound 0) (btpos b) 1 Nothing $ w . soundFromGeneral (LeverSound 0) (btpos b) click1S Nothing $ w
, _btID = 0 , _btID = 0
, _btText = "Button" , _btText = "Button"
--, _btText = "Button" --, _btText = "Button"
@@ -45,7 +46,7 @@ makeSwitch c effOn effOff = Button
, _btState = BtOff , _btState = BtOff
} }
where where
flipSwitch b w = switchEffect b . soundFromGeneral (LeverSound 0) (bpos b) 1 Nothing $ w flipSwitch b w = switchEffect b . soundFromGeneral (LeverSound 0) (bpos b) click1S Nothing $ w
bpos b w = _btPos $ _buttons w IM.! _btID b bpos b w = _btPos $ _buttons w IM.! _btID b
switchEffect b = case _btState b of switchEffect b = case _btState b of
BtOff -> effOn . over buttons (IM.adjust turnOn (_btID b)) BtOff -> effOn . over buttons (IM.adjust turnOn (_btID b))
+7 -6
View File
@@ -11,6 +11,7 @@ import Dodge.WorldEvent
import Dodge.Particle.Bullet.Spawn import Dodge.Particle.Bullet.Spawn
import Dodge.WorldEvent.DamageBlock import Dodge.WorldEvent.DamageBlock
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.LoadSound
import Dodge.RandomHelp import Dodge.RandomHelp
import Dodge.WorldEvent.Shockwave import Dodge.WorldEvent.Shockwave
import Dodge.Creature.State.Data import Dodge.Creature.State.Data
@@ -37,7 +38,7 @@ bulHitCr bt p cr w
mvDams = [ PushDam 1 $ 2 *.* bulVel ] mvDams = [ PushDam 1 $ 2 *.* bulVel ]
addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ ) addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ )
addDamageArmoured = creatures . ix cid . crState . crDamage %~ (mvDams ++) addDamageArmoured = creatures . ix cid . crState . crDamage %~ (mvDams ++)
makeHitSound = soundMultiFrom [CrHitSound 0] p 15 (Just 10) makeHitSound = soundMultiFrom [CrHitSound 0] p hit1S (Just 10)
flashEff = over worldEvents (bloodFlashAt p . ) flashEff = over worldEvents (bloodFlashAt p . )
cid = _crID cr cid = _crID cr
(d1,_) = randomR (-0.7,0.7) $ _randGen w (d1,_) = randomR (-0.7,0.7) $ _randGen w
@@ -55,7 +56,7 @@ bulBounceArmCr' bt p cr w
mvDams = [ PushDam 1 $ 2 *.* bulVel ] mvDams = [ PushDam 1 $ 2 *.* bulVel ]
addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ ) addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ )
addDamageArmoured = creatures . ix cid . crState . crDamage %~ (mvDams ++) addDamageArmoured = creatures . ix cid . crState . crDamage %~ (mvDams ++)
makeHitSound = soundMultiFrom [CrHitSound 0] p 15 (Just 10) makeHitSound = soundMultiFrom [CrHitSound 0] p hit1S (Just 10)
flashEff = over worldEvents ((.) $ bloodFlashAt p) flashEff = over worldEvents ((.) $ bloodFlashAt p)
cid = _crID cr cid = _crID cr
newDir = safeNormalizeV (p -.- _crPos cr) newDir = safeNormalizeV (p -.- _crPos cr)
@@ -76,7 +77,7 @@ bulPenCr' bt p cr w
] ]
++ ++
) )
$ soundMultiFrom [CrHitSound 0] ep 15 (Just 10) $ soundMultiFrom [CrHitSound 0] ep hit1S (Just 10)
$ over worldEvents (addPiercer . ) $ over worldEvents (addPiercer . )
w w
where where
@@ -100,7 +101,7 @@ hvBulHitCr bt p cr w
] ]
++ ++
) )
$ soundMultiFrom [CrHitSound 0] ep 15 (Just 10) $ soundMultiFrom [CrHitSound 0] ep hit1S (Just 10)
w w
where where
(d1,_) = randomR (-0.7,0.7) $ _randGen w (d1,_) = randomR (-0.7,0.7) $ _randGen w
@@ -112,7 +113,7 @@ bulIncCr' :: Particle -> Point2 -> Creature -> World -> World
bulIncCr' bt p cr w bulIncCr' bt p cr w
= over (creatures . ix cid . crState . crDamage) = over (creatures . ix cid . crState . crDamage)
( Piercing 60 sp p ep : ) ( Piercing 60 sp p ep : )
. soundMultiFrom [CrHitSound 0] p 15 (Just 10) . soundMultiFrom [CrHitSound 0] p hit1S (Just 10)
$ incFlamelets $ incFlamelets
w w
where where
@@ -126,7 +127,7 @@ bulConCr' :: Particle -> Point2 -> Creature -> World -> World
bulConCr' bt p cr w bulConCr' bt p cr w
= over (creatures . ix cid . crState . crDamage) = over (creatures . ix cid . crState . crDamage)
( Piercing 60 sp p ep : ) ( Piercing 60 sp p ep : )
. soundMultiFrom [CrHitSound 0] p 15 (Just 10) . soundMultiFrom [CrHitSound 0] p hit1S (Just 10)
$ mkwave $ mkwave
w w
where where
+2 -1
View File
@@ -10,6 +10,7 @@ import Dodge.Picture.SizeInvariant
import Dodge.Picture.Layer import Dodge.Picture.Layer
import Dodge.Render.HUD import Dodge.Render.HUD
import Dodge.Render.MenuScreen import Dodge.Render.MenuScreen
import Dodge.SoundLogic.LoadSound
import Sound.Data import Sound.Data
import Geometry import Geometry
import Picture import Picture
@@ -77,7 +78,7 @@ soundPic :: World -> Sound -> Picture
soundPic w s = fixedSizePicClampArrow 50 50 thePic p w soundPic w s = fixedSizePicClampArrow 50 50 thePic p w
where where
p = _soundPos s p = _soundPos s
thePic = scale 0.15 0.15 $ text "SOUND" thePic = scale 0.15 0.15 $ text $ soundToOnomato $ _soundChunkID s
crDraw :: World -> Creature -> Picture crDraw :: World -> Creature -> Picture
crDraw w c = _crPict c c w crDraw w c = _crPict c c w
+9 -8
View File
@@ -23,6 +23,7 @@ import Sound.Data
import Geometry.Data import Geometry.Data
import Geometry.Vector import Geometry.Vector
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.Synonyms
import Dodge.SoundLogic.LoadSound
import Control.Lens import Control.Lens
import qualified Data.Map as M import qualified Data.Map as M
@@ -44,7 +45,7 @@ resumeSound w = w
For each origin only one sound will play at a time. For each origin only one sound will play at a time.
-} -}
soundOnceOrigin soundOnceOrigin
:: Int -- ^ ID of the sound to be played :: SoundID -- ^ ID of the sound to be played
-> SoundOrigin -- ^ The \"creator\" of the sound -> SoundOrigin -- ^ The \"creator\" of the sound
-> Point2 -- ^ The position of the sound in the world -> Point2 -- ^ The position of the sound in the world
-> World -> World
@@ -58,14 +59,14 @@ soundOnceOrigin sType so p w = w & sounds %~ M.insertWith (\ _ x -> x) so theSou
, _soundChannel = Nothing , _soundChannel = Nothing
, _soundAngDist = Just (a,0) , _soundAngDist = Just (a,0)
, _soundPos = p , _soundPos = p
, _soundVolume = soundVolID sType , _soundVolume = soundToVol sType
} }
a = soundAngle p w a = soundAngle p w
soundFrom soundFrom
:: SoundOrigin -- ^ \"Creator\" of sound :: SoundOrigin -- ^ \"Creator\" of sound
-> Point2 -- ^ Position of sound -> Point2 -- ^ Position of sound
-> Int -- ^ ID of sound to be played -> SoundID -- ^ ID of sound to be played
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished -> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
-> World -> World
-> World -> World
@@ -78,7 +79,7 @@ soundFrom so pos sType mtime w = over sounds (M.insertWith f so sound) w
, _soundChannel = Nothing , _soundChannel = Nothing
, _soundAngDist = Just (a,0) , _soundAngDist = Just (a,0)
, _soundPos = pos , _soundPos = pos
, _soundVolume = soundVolID sType , _soundVolume = soundToVol sType
} }
f _ s = s {_soundTime = mtime } f _ s = s {_soundTime = mtime }
a = soundAngle pos w a = soundAngle pos w
@@ -86,7 +87,7 @@ soundFrom so pos sType mtime w = over sounds (M.insertWith f so sound) w
soundFromGeneral soundFromGeneral
:: SoundOrigin -- ^ \"Creator\" of sound :: SoundOrigin -- ^ \"Creator\" of sound
-> (World -> Point2) -- ^ Position of sound -> (World -> Point2) -- ^ Position of sound
-> Int -- ^ ID of sound to be played -> SoundID -- ^ ID of sound to be played
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished -> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
-> World -> World
-> World -> World
@@ -99,7 +100,7 @@ soundFromGeneral so fpos sType mtime w = over sounds (M.insertWith f so sound) w
, _soundChannel = Nothing , _soundChannel = Nothing
, _soundAngDist = Just (a,0) , _soundAngDist = Just (a,0)
, _soundPos = fpos w , _soundPos = fpos w
, _soundVolume = soundVolID sType , _soundVolume = soundToVol sType
} }
f _ s = s {_soundTime = mtime } f _ s = s {_soundTime = mtime }
a = soundAngle (fpos w) w a = soundAngle (fpos w) w
@@ -124,7 +125,7 @@ Does nothing if all origins are already creating sounds. -}
soundMultiFrom soundMultiFrom
:: [SoundOrigin] :: [SoundOrigin]
-> Point2 -- ^ Position -> Point2 -- ^ Position
-> Int -- ^ Sound ID -> SoundID -- ^ Sound ID
-> Maybe Int -- ^ Frames to play for, Nothing for full length -> Maybe Int -- ^ Frames to play for, Nothing for full length
-> World -> World
-> World -> World
@@ -140,7 +141,7 @@ soundMultiFrom (so:sos) pos sType mtime w
, _soundChannel = Nothing , _soundChannel = Nothing
, _soundAngDist = Just (a,0) , _soundAngDist = Just (a,0)
, _soundPos = pos , _soundPos = pos
, _soundVolume = soundVolID sType , _soundVolume = soundToVol sType
} }
a = soundAngle pos w a = soundAngle pos w
{- | Sets '_soundTime' to 0. -} {- | Sets '_soundTime' to 0. -}
+308 -94
View File
@@ -1,104 +1,318 @@
module Dodge.SoundLogic.LoadSound where module Dodge.SoundLogic.LoadSound where
import Sound.Data
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
import qualified SDL.Mixer as Mix import qualified SDL.Mixer as Mix
loadSound :: (Int,String) -> IO (Int, Mix.Chunk)
loadSound (i,s) = do
chnk <- Mix.load $ "./data/sound/" ++ s
return (i,chnk)
loadSounds :: IO (IM.IntMap Mix.Chunk) loadSounds :: IO (IM.IntMap Mix.Chunk)
loadSounds = do loadSounds = do
Mix.openAudio Mix.defaultAudio 128 Mix.openAudio Mix.defaultAudio 128
pFireSound <- Mix.load "./data/sound/tap3.wav" fmap IM.fromList $ mapM loadSound $ zip [0..] soundPathList
click <- Mix.load "./data/sound/click1.wav"
reloadSound' <- Mix.load "./data/sound/reload1.wav" soundToVol :: SoundID -> Float
tone440 <- Mix.load "./data/sound/tone440.wav" soundToVol v = case _getSoundID v of
pickupSound' <- Mix.load "./data/sound/pickUp.wav" 0 -> 20
putdownSound' <- Mix.load "./data/sound/whiteNoiseFadeOut.wav" 1 -> 80
fireSound' <- Mix.load "./data/sound/fire1.wav" 2 -> 40
grenadeBang' <- Mix.load "./data/sound/grenade.wav" 3 -> 30
tapQuiet' <- Mix.load "./data/sound/tapQuiet.wav" 4 -> 30
twoStep' <- Mix.load "./data/sound/twoStep.wav" 5 -> 100
healSound' <- Mix.load "./data/sound/heal.wav" 6 -> 50
doorSound' <- Mix.load "./data/sound/slideDoor.wav" 7 -> 20
twoStepSlow' <- Mix.load "./data/sound/twoStepSlow.wav" 8 -> 200
knifeSound' <- Mix.load "./data/sound/knife.wav" 9 -> 100
buzzSound' <- Mix.load "./data/sound/buzz.wav" 10 -> 50
hitSound' <- Mix.load "./data/sound/hit1.wav" 11 -> 80
autoGunSound' <- Mix.load "./data/sound/autoGun.wav" 12 -> 30
shotgunSound' <- Mix.load "./data/sound/shotgun.wav" 13 -> 80
teleSound' <- Mix.load "./data/sound/tele.wav" 14 -> 120
longGunSound' <- Mix.load "./data/sound/longTap.wav" 15 -> 50
launcherSound' <- Mix.load "./data/sound/tap4.wav" 16 -> 30
smokeTrailSound' <- Mix.load "./data/sound/missileLaunch.wav" 17 -> 100
foot1Sound' <- Mix.load "./data/sound/foot1.wav" 18 -> 80
foot2Sound' <- Mix.load "./data/sound/foot2.wav" 19 -> 50
lasSound' <- Mix.load "./data/sound/tone440sawtooth.wav" 20 -> 100
teslaSound' <- Mix.load "./data/sound/Electrical-Welding.wav" 21 -> 120
crankSlow' <- Mix.load "./data/sound/crankSlow.wav" 22 -> 20
autoB' <- Mix.load "./data/sound/autoB.wav" 23 -> 20
mini' <- Mix.load "./data/sound/mini1.wav" 24 -> 80
impactA' <- Mix.load "./data/sound/Impact-A.wav" 25 -> 30
impactB' <- Mix.load "./data/sound/Impact-B.wav" 26 -> 80
impactC' <- Mix.load "./data/sound/Impact-C.wav" 27 -> 80
impactD' <- Mix.load "./data/sound/Impact-D.wav" 28 -> 80
glassShat1' <- Mix.load "./data/sound/Glass-Bottle-Shattering-A1.wav" 29 -> 50
glassShat2' <- Mix.load "./data/sound/Glass-Bottle-Shattering-A2.wav" 30 -> 30
glassShat3' <- Mix.load "./data/sound/Glass-Bottle-Shattering-A3.wav" 31 -> 40
glassShat4' <- Mix.load "./data/sound/Glass-Bottle-Shattering-A4.wav" 32 -> 50
glass1' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A1.wav" 33 -> 50
glass2' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A2.wav" 34 -> 80
glass3' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A3.wav" 35 -> 80
glass4' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A4.wav" 36 -> 60
foamSpray <- Mix.load "./data/sound/foamSprayLoop.wav" 37 -> 40
foamSprayFadeOut <- Mix.load "./data/sound/foamSprayFadeOut.wav" 38 -> 150
sineRaisePitchOneSec <- Mix.load "./data/sound/sineRaisePitchOneSec.wav" 39 -> 40
sineRaisePitchTwoSec <- Mix.load "./data/sound/sineRaisePitchTwoSec.wav" 40 -> 50
skwareFadeTwoSec <- Mix.load "./data/sound/skwareFadeTwoSec.wav" 41 -> 40
return $ IM.fromList $ zip [0..] 42 -> 30
[ pFireSound 43 -> 80
, click 44 -> 80
, reloadSound' 45 -> 20
, tone440 46 -> 80
, pickupSound' 47 -> 50
, putdownSound' 48 -> 50
, fireSound' 49 -> 30
, grenadeBang' 50 -> 100
, tapQuiet' 51 -> 50
, twoStep' 52 -> 150
, healSound' 53 -> 100
, doorSound' 54 -> 80
, twoStepSlow' 55 -> 30
, knifeSound' 56 -> 100
, buzzSound' 57 -> 100
, hitSound' --15 _ -> 50
, autoGunSound' soundToOnomato :: SoundID -> String
, shotgunSound' soundToOnomato v = case _getSoundID v of
, teleSound' 0 -> "BLIH"
, longGunSound' 1 -> "CRNK"
, launcherSound' 2 -> "BRAP"
, smokeTrailSound' 3 -> "TIP"
, foot1Sound' 4 -> "THUD"
, foot2Sound' 5 -> "BRAP"
, lasSound' 6 -> "CRTINK"
, teslaSound' --25 7 -> "SHUHP"
, crankSlow' 8 -> "BOOM"
, autoB' 9 -> "WHSSH"
, mini' 10 -> "KRTNKL"
, impactA' 11 -> "CRUMPLE"
, impactB' --30 12 -> "TAP"
, impactC' 13 -> "CRUNK"
, impactD' 14 -> "BRDBRDBRD"
, glassShat1' --33 15 -> "WRR"
, glassShat2' 16 -> "DRR"
, glassShat3' 17 -> "TATATA"
, glassShat4' 18 -> "TAK"
, glass1' --37 19 -> "TRINKL"
, glass2' 20 -> "SCREE"
, glass3' 21 -> "BRPBRPBRP"
, glass4' --40 22 -> "PHF"
, foamSpray 23 -> "FHP"
, foamSprayFadeOut 24 -> "CRSNK"
, sineRaisePitchOneSec 25 -> "BWAAH"
, sineRaisePitchTwoSec 26 -> "RINGGG"
, skwareFadeTwoSec 27 -> "ZMM"
] 28 -> "BRAP"
29 -> "HNH"
30 -> "CHPCHPCHP"
31 -> "SMACK"
32 -> "HSSS"
33 -> "HSS"
34 -> "CRSK"
35 -> "CRASH"
36 -> "TAPTIP"
37 -> "TIPTOP"
38 -> "BANG"
39 -> "TIPTAP"
40 -> "THUD"
41 -> "TAPP"
42 -> "DWAAH"
43 -> "TAKH"
44 -> "BEP"
45 -> "SWSH"
46 -> "CRNKL"
47 -> "CHNKCHNKCHUNK"
48 -> "TINKLE"
49 -> "TNKTNKTNK"
50 -> "BRAHCHCH"
51 -> "CLICK"
52 -> "BANGG"
53 -> "WRRR"
54 -> "CRISH"
55 -> "BWAH"
56 -> "CRAKLE"
57 -> "ZHM"
_ -> error "unitialised sound"
soundPathList :: [String]
soundPathList =
[ "heal.BLIH.20.wav"
, "glassShat3.CRNK.80.wav"
, "tapQuiet.BRAP.40.wav"
, "foot1.TIP.30.wav"
, "hit.THUD.30.wav"
, "autoGun.BRAP.100.wav"
, "smallGlass3.CRTINK.50.wav"
, "pickUp.SHUHP.20.wav"
, "explosion.BOOM.200.wav"
, "missileLaunch.WHSSH.100.wav"
, "smallGlass2.KRTNKL.50.wav"
, "impact3.CRUMPLE.80.wav"
, "foot2.TAP.30.wav"
, "impact2.CRUNK.80.wav"
, "mini1.BRDBRDBRD.120.wav"
, "fire.WRR.50.wav"
, "slideDoor.DRR.30.wav"
, "autoB.TATATA.100.wav"
, "tap1.TAK.80.wav"
, "smallGlass1.TRINKL.50.wav"
, "tone440sawtooth.SCREE.100.wav"
, "mini.BRPBRPBRP.120.wav"
, "whiteNoiseFadeOut.PHF.20.wav"
, "whiteNoiseFadeIn.FHP.20.wav"
, "glassShat1.CRSNK.80.wav"
, "sineRaisePitchTwoSec.BWAAH.30.wav"
, "tinitus.RINGGG.80.wav"
, "buzz.ZMM.80.wav"
, "tap3.BRAP.80.wav"
, "grunt.HNH.50.wav"
, "reload1.CHPCHPCHP.30.wav"
, "hit1.SMACK.40.wav"
, "foamSprayLoop.HSSS.50.wav"
, "foamSprayFadeOut.HSS.50.wav"
, "glassShat4.CRSK.80.wav"
, "impact1.CRASH.80.wav"
, "twoStep1.TAPTIP.60.wav"
, "twoStepSlow.TIPTOP.40.wav"
, "bang.BANG.150.wav"
, "twoStep.TIPTAP.40.wav"
, "tap4.THUD.50.wav"
, "foot3.TAPP.40.wav"
, "skwareFadeTwoSec.DWAAH.30.wav"
, "tap2.TAKH.80.wav"
, "tone440.BEP.80.wav"
, "knife.SWSH.20.wav"
, "glassShat2.CRNKL.80.wav"
, "crankSlow.CHNKCHNKCHUNK.50.wav"
, "smallGlass4.TINKLE.50.wav"
, "reload.TNKTNKTNK.30.wav"
, "shotgun.BRAHCHCH.100.wav"
, "click1.CLICK.50.wav"
, "bangEcho.BANGG.150.wav"
, "fireLoud.WRRR.100.wav"
, "impact4.CRISH.80.wav"
, "sineRaisePitchOneSec.BWAH.30.wav"
, "elecCrackle.CRAKLE.100.wav"
, "tele.ZHM.100.wav"
]
healS :: SoundID
healS = SoundID 0
glassShat3S :: SoundID
glassShat3S = SoundID 1
tapQuietS :: SoundID
tapQuietS = SoundID 2
foot1S :: SoundID
foot1S = SoundID 3
hitS :: SoundID
hitS = SoundID 4
autoGunS :: SoundID
autoGunS = SoundID 5
smallGlass3S :: SoundID
smallGlass3S = SoundID 6
pickUpS :: SoundID
pickUpS = SoundID 7
explosionS :: SoundID
explosionS = SoundID 8
missileLaunchS :: SoundID
missileLaunchS = SoundID 9
smallGlass2S :: SoundID
smallGlass2S = SoundID 10
impact3S :: SoundID
impact3S = SoundID 11
foot2S :: SoundID
foot2S = SoundID 12
impact2S :: SoundID
impact2S = SoundID 13
mini1S :: SoundID
mini1S = SoundID 14
fireS :: SoundID
fireS = SoundID 15
slideDoorS :: SoundID
slideDoorS = SoundID 16
autoBS :: SoundID
autoBS = SoundID 17
tap1S :: SoundID
tap1S = SoundID 18
smallGlass1S :: SoundID
smallGlass1S = SoundID 19
tone440sawtoothS :: SoundID
tone440sawtoothS = SoundID 20
miniS :: SoundID
miniS = SoundID 21
whiteNoiseFadeOutS :: SoundID
whiteNoiseFadeOutS = SoundID 22
whiteNoiseFadeInS :: SoundID
whiteNoiseFadeInS = SoundID 23
glassShat1S :: SoundID
glassShat1S = SoundID 24
sineRaisePitchTwoSecS :: SoundID
sineRaisePitchTwoSecS = SoundID 25
tinitusS :: SoundID
tinitusS = SoundID 26
buzzS :: SoundID
buzzS = SoundID 27
tap3S :: SoundID
tap3S = SoundID 28
gruntS :: SoundID
gruntS = SoundID 29
reload1S :: SoundID
reload1S = SoundID 30
hit1S :: SoundID
hit1S = SoundID 31
foamSprayLoopS :: SoundID
foamSprayLoopS = SoundID 32
foamSprayFadeOutS :: SoundID
foamSprayFadeOutS = SoundID 33
glassShat4S :: SoundID
glassShat4S = SoundID 34
impact1S :: SoundID
impact1S = SoundID 35
twoStep1S :: SoundID
twoStep1S = SoundID 36
twoStepSlowS :: SoundID
twoStepSlowS = SoundID 37
bangS :: SoundID
bangS = SoundID 38
twoStepS :: SoundID
twoStepS = SoundID 39
tap4S :: SoundID
tap4S = SoundID 40
foot3S :: SoundID
foot3S = SoundID 41
skwareFadeTwoSecS :: SoundID
skwareFadeTwoSecS = SoundID 42
tap2S :: SoundID
tap2S = SoundID 43
tone440S :: SoundID
tone440S = SoundID 44
knifeS :: SoundID
knifeS = SoundID 45
glassShat2S :: SoundID
glassShat2S = SoundID 46
crankSlowS :: SoundID
crankSlowS = SoundID 47
smallGlass4S :: SoundID
smallGlass4S = SoundID 48
reloadS :: SoundID
reloadS = SoundID 49
shotgunS :: SoundID
shotgunS = SoundID 50
click1S :: SoundID
click1S = SoundID 51
bangEchoS :: SoundID
bangEchoS = SoundID 52
fireLoudS :: SoundID
fireLoudS = SoundID 53
impact4S :: SoundID
impact4S = SoundID 54
sineRaisePitchOneSecS :: SoundID
sineRaisePitchOneSecS = SoundID 55
elecCrackleS :: SoundID
elecCrackleS = SoundID 56
teleS :: SoundID
teleS = SoundID 57
loadMusic :: IO (IM.IntMap Mix.Music) loadMusic :: IO (IM.IntMap Mix.Music)
loadMusic = do loadMusic = do
+4 -4
View File
@@ -12,7 +12,7 @@ import Dodge.WorldEvent.SpawnParticle
--import Dodge.WorldEvent.Flash --import Dodge.WorldEvent.Flash
import Dodge.RandomHelp import Dodge.RandomHelp
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Dodge.WorldEvent.Shockwave import Dodge.WorldEvent.Shockwave
import Geometry import Geometry
import Geometry.Vector3D import Geometry.Vector3D
@@ -30,7 +30,7 @@ makePoisonExplosionAt
-> World -> World
-> World -> World
makePoisonExplosionAt p w makePoisonExplosionAt p w
= soundMultiFrom [Explosion 0,Explosion 1] p grenadeBang Nothing = soundMultiFrom [Explosion 0,Explosion 1] p bangS Nothing
$ foldr (makeGasCloud p) w vels $ foldr (makeGasCloud p) w vels
where where
vels = replicateM 25 (randInCirc 2) & evalState $ _randGen w vels = replicateM 25 (randInCirc 2) & evalState $ _randGen w
@@ -58,7 +58,7 @@ makeFlameExplosionAt
-> World -> World
-> World -> World
makeFlameExplosionAt p w makeFlameExplosionAt p w
= soundMultiFrom [Explosion 0,Explosion 1] p grenadeBang Nothing = soundMultiFrom [Explosion 0,Explosion 1] p bangS Nothing
$ over particles (newFlames ++ ) w $ over particles (newFlames ++ ) w
where where
newFlames = zipWith makeFlameWithVelAndTime velocities timers newFlames = zipWith makeFlameWithVelAndTime velocities timers
@@ -73,7 +73,7 @@ makeExplosionAt
-> World -> World
-> World -> World
makeExplosionAt p w makeExplosionAt p w
= soundMultiFrom [Explosion 0,Explosion 1] p grenadeBang Nothing = soundMultiFrom [Explosion 0,Explosion 1] p bangS Nothing
. addFlames . addFlames
-- . explosionFlashAt p -- . explosionFlashAt p
. over tempLightSources (theTLS :) . over tempLightSources (theTLS :)
+7 -3
View File
@@ -3,17 +3,21 @@ module Dodge.WorldEvent.Sound
import Dodge.Data import Dodge.Data
import Dodge.Data.SoundOrigin import Dodge.Data.SoundOrigin
import Dodge.SoundLogic import Dodge.SoundLogic
import System.Random import Dodge.SoundLogic.LoadSound
import Geometry.Data import Geometry.Data
import Dodge.RandomHelp
import System.Random
import Control.Lens import Control.Lens
import Control.Monad.State.Lazy
mkSoundBreakGlass :: Point2 -> World -> World mkSoundBreakGlass :: Point2 -> World -> World
mkSoundBreakGlass p w = soundOnceOrigin soundid (GlassBreakSound 0) p $ set randGen g w mkSoundBreakGlass p w = soundOnceOrigin soundid (GlassBreakSound 0) p $ set randGen g w
where where
(soundid,g) = _randGen w & randomR (37,40) (soundid,g) = _randGen w & runState (takeOne [glassShat1S,glassShat2S,glassShat3S,glassShat4S])
mkSoundSplinterGlass :: Point2 -> World -> World mkSoundSplinterGlass :: Point2 -> World -> World
mkSoundSplinterGlass p w = soundOnceOrigin soundid (GlassBreakSound 1) p $ set randGen g w mkSoundSplinterGlass p w = soundOnceOrigin soundid (GlassBreakSound 1) p $ set randGen g w
where where
(soundid,g) = _randGen w & randomR (33,36) (soundid,g) = _randGen w & runState (takeOne [smallGlass1S,smallGlass2S,smallGlass3S,smallGlass4S])
+2 -2
View File
@@ -20,7 +20,7 @@ import Dodge.WorldEvent.Cloud
import Dodge.Particle.Bullet.Draw import Dodge.Particle.Bullet.Draw
import Dodge.Particle.Bullet.Update import Dodge.Particle.Bullet.Update
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms import Dodge.SoundLogic.LoadSound
import Dodge.RandomHelp import Dodge.RandomHelp
--import Dodge.Debug --import Dodge.Debug
import Picture import Picture
@@ -99,7 +99,7 @@ moveFlame rotd w pt
_ -> (glare $ doSound damcrs , mvPt) _ -> (glare $ doSound damcrs , mvPt)
where where
time = _btTimer' pt time = _btTimer' pt
doSound = soundFrom Flame (V2 x y) fireSound (Just 2) -- . over worldEvents ((.) $ flameGlareAt ep) doSound = soundFrom Flame (V2 x y) fireS (Just 2) -- . over worldEvents ((.) $ flameGlareAt ep)
glare glare
| time `mod` 5 == 0 | time `mod` 5 == 0
= tempLightSources %~ (theTLS :) = tempLightSources %~ (theTLS :)
+1 -1
View File
@@ -82,7 +82,7 @@ tryPlay sd s = do
i <- tryGetChannel s i <- tryGetChannel s
_ <- liftIO $ do _ <- liftIO $ do
Mix.halt i Mix.halt i
Mix.playOn i Mix.Once (sd IM.! _soundChunkID s) Mix.playOn i Mix.Once (sd IM.! (_getSoundID $ _soundChunkID s))
return $ s return $ s
& soundChannel ?~ i & soundChannel ?~ i
& soundStatus .~ JustStartedPlaying & soundStatus .~ JustStartedPlaying
+4 -1
View File
@@ -15,6 +15,9 @@ data SoundStatus
| ToStart | ToStart
deriving (Eq,Ord,Show) deriving (Eq,Ord,Show)
newtype SoundID = SoundID { _getSoundID :: Int }
deriving (Eq,Ord,Show)
newtype SoundData = SoundData newtype SoundData = SoundData
{_loadedChunks :: IM.IntMap Mix.Chunk {_loadedChunks :: IM.IntMap Mix.Chunk
} }
@@ -25,7 +28,7 @@ data Sound = Sound
, _soundAngDist :: Maybe (Int16,Word8) , _soundAngDist :: Maybe (Int16,Word8)
, _soundPos :: Point2 , _soundPos :: Point2
, _soundVolume :: Float , _soundVolume :: Float
, _soundChunkID :: Int , _soundChunkID :: SoundID
} }
deriving (Eq,Ord,Show) deriving (Eq,Ord,Show)