Refactor sounds
This commit is contained in:
@@ -44,10 +44,10 @@ killBlock bl w = f bl . flip (foldr unshadow) (_blShadows bl) $ w
|
||||
pos = fst $ _wlLine bl
|
||||
breakHitSound bl'
|
||||
| _wlIsSeeThrough bl' = mkSoundBreakGlass pos
|
||||
| otherwise = soundMultiFrom sos soundid 25 0
|
||||
| otherwise = soundMultiFrom sos (fst $ _wlLine bl') (soundid + 4) Nothing
|
||||
hitSound' bl'
|
||||
| _wlIsSeeThrough bl' = mkSoundSplinterGlass pos
|
||||
| otherwise = soundMultiFrom sos soundid 25 0
|
||||
| otherwise = soundMultiFrom sos (fst $ _wlLine bl') soundid Nothing
|
||||
sos = [BlockDegradeSound 0,BlockDegradeSound 1]
|
||||
(soundid,_) = randomR (29,32) $ _randGen w
|
||||
unshadow :: Int -> World -> World
|
||||
|
||||
@@ -65,7 +65,7 @@ addSoundToDoor i pld hwd (x:ys) = f x : ys
|
||||
where
|
||||
g dm w
|
||||
| dist wp pld > 2 && dist wp hwd > 2
|
||||
= soundFrom (WallSound i) doorSound 1 0 $ dm w
|
||||
= soundFrom (WallSound i) wp doorSound (Just 1) $ dm w
|
||||
| otherwise = dm w
|
||||
where
|
||||
wp = snd $ _wlLine (_walls w IM.! i)
|
||||
|
||||
@@ -18,11 +18,7 @@ makeButton c eff = Button
|
||||
, _btPos = V2 0 0
|
||||
, _btRot = 0
|
||||
, _btEvent = \b w -> eff . over buttons (IM.adjust turnOn (_btID b))
|
||||
-- . set (buttons . ix (_btID b) . btPict)
|
||||
-- (onLayer WlLayer $ color c $ polygon $ rectNSEW (-3) (-5) 10 (-10))
|
||||
-- . set (buttons . ix (_btID b) . btState) BtNoLabel
|
||||
-- . set (buttons . ix (_btID b) . btEvent) (\b -> return)
|
||||
. soundOnce 1 $ w
|
||||
. soundFromGeneral (LeverSound 0) (btpos b) 1 Nothing $ w
|
||||
, _btID = 0
|
||||
, _btText = "Button"
|
||||
--, _btText = "Button"
|
||||
@@ -31,6 +27,7 @@ makeButton c eff = Button
|
||||
where
|
||||
turnOn bt = bt {_btState = BtNoLabel, _btPict = onPict, _btEvent = const id}
|
||||
onPict = setLayer 0 $ onLayer WlLayer (color c $ polygon $ rectNSEW (-3) (-5) 10 (-10))
|
||||
btpos b w' = _btPos $ _buttons w' IM.! _btID b
|
||||
|
||||
makeSwitch
|
||||
:: Color
|
||||
@@ -47,7 +44,8 @@ makeSwitch c effOn effOff = Button
|
||||
, _btState = BtOff
|
||||
}
|
||||
where
|
||||
flipSwitch b w = switchEffect b . soundOnce 1 $ w
|
||||
flipSwitch b w = switchEffect b . soundFromGeneral (LeverSound 0) (bpos b) 1 Nothing $ w
|
||||
bpos b w = _btPos $ _buttons w IM.! _btID b
|
||||
switchEffect b = case _btState b of
|
||||
BtOff -> effOn . over buttons (IM.adjust turnOn (_btID b))
|
||||
BtOn -> effOff . over buttons (IM.adjust turnOff (_btID b))
|
||||
|
||||
Reference in New Issue
Block a user