diff --git a/appDodge/Main.hs b/appDodge/Main.hs index b5c9a6cc0..d269f9846 100644 --- a/appDodge/Main.hs +++ b/appDodge/Main.hs @@ -26,7 +26,7 @@ import Control.Lens --import Foreign (Word32) import Control.Monad --import System.Random -import qualified Data.Map as M +--import qualified Data.Map as M import qualified Data.IntMap as IM import Graphics.Rendering.OpenGL hiding (color, rotate, scale, translate) import qualified SDL @@ -75,6 +75,7 @@ doSideEffects w = do ) newpdata <- foldr (=<<) (return (preData & frameTimer .~ endTicks)) (_doneSideEffects w) return $ w & preloadData .~ newpdata + & playingSounds .~ newPlayingSounds doPreload :: IO PreloadData doPreload = do diff --git a/src/Dodge/Config/Update.hs b/src/Dodge/Config/Update.hs index 09253ebff..998b3ad32 100644 --- a/src/Dodge/Config/Update.hs +++ b/src/Dodge/Config/Update.hs @@ -3,7 +3,7 @@ IO actions that apply config side effects and save configuration settings to dis -} module Dodge.Config.Update where -import Dodge.Data.SoundOrigin +--import Dodge.Data.SoundOrigin import Dodge.Config.Data import Sound import Data.Preload diff --git a/src/Dodge/Creature/Perception.hs b/src/Dodge/Creature/Perception.hs index fe554d839..f956fd173 100644 --- a/src/Dodge/Creature/Perception.hs +++ b/src/Dodge/Creature/Perception.hs @@ -10,7 +10,7 @@ import Dodge.Creature.Memory.Data import Dodge.Base.Collide import Geometry.Vector --import Geometry.Data ---import Sound.Data +import Sound.Data --import StrictHelp import Data.Maybe @@ -88,12 +88,11 @@ awakeLevelPerception cr = case _crAwakeLevel $ _crPerception cr of Overstrung -> 10000 newSounds :: World -> [(Point2,Float)] -newSounds = mapMaybe f . M.elems . _sounds +newSounds = mapMaybe f . M.elems . _playingSounds where - f s = Just (_soundPos s, _soundVolume s) --- f s | _soundStatus s == JustStartedPlaying --- = Just (_soundPos s, _soundVolume s) --- | otherwise = Nothing + f s | _soundStatus s == JustStartedPlaying + = Just (_soundPos s, _soundVolume s) + | otherwise = Nothing rememberSounds :: Creature -> Reader World Creature rememberSounds cr = do @@ -102,4 +101,4 @@ rememberSounds cr = do -- return $ cr & crMemory . soundsToInvestigate .~ [V2 0 0] soundIsClose :: Creature -> (Point2,Float) -> Bool -soundIsClose cr (pos,vol) = True -- vol > (_auDist . _crAudition $ _crPerception cr) (dist pos (_crPos cr)) +soundIsClose cr (pos,vol) = vol > (_auDist . _crAudition $ _crPerception cr) (dist pos (_crPos cr)) diff --git a/src/Dodge/Creature/Picture.hs b/src/Dodge/Creature/Picture.hs index 2e433bbf2..eb43fe6b2 100644 --- a/src/Dodge/Creature/Picture.hs +++ b/src/Dodge/Creature/Picture.hs @@ -66,7 +66,7 @@ creatureDisplayText w cr (V2 x y) = campos +.+ v +.+ _crRad cr *.* normalizeV v creatureDisplayString :: Creature -> String -creatureDisplayString cr = show . _soundsToInvestigate $ _crMemory cr +creatureDisplayString cr = show . take 1 . _soundsToInvestigate $ _crMemory cr -- | isAsleep = "Z" -- | isSuspicious = "?" -- | otherwise = "" diff --git a/src/Dodge/Creature/ReaderUpdate.hs b/src/Dodge/Creature/ReaderUpdate.hs index 134161686..18004d88b 100644 --- a/src/Dodge/Creature/ReaderUpdate.hs +++ b/src/Dodge/Creature/ReaderUpdate.hs @@ -47,7 +47,9 @@ tryMeleeAttack cr tcr setMvPos :: Creature -> Reader World Creature setMvPos cr = pure $ cr & crMvTarget .~ mpos where - mpos = (_crPos <$> _crTarget cr) <|> listToMaybe (_soundsToInvestigate $ _crMemory cr) + mpos = (_crPos <$> _crTarget cr) + <|> _crMvTarget cr + <|> listToMaybe (_soundsToInvestigate $ _crMemory cr) setTargetMv :: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index 4e1be8da8..1ce58ebd5 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -84,7 +84,7 @@ defaultVision = Eyes | otherwise = 1 defaultAudition :: Audition defaultAudition = Ears - { _auDist = \x -> 1 / (x * x) + { _auDist = \x -> x * x } defaultChaseMvType :: CrMvType defaultChaseMvType = ChaseMvType diff --git a/src/Dodge/Initialisation.hs b/src/Dodge/Initialisation.hs index 09c88d40b..a91a0d3a8 100644 --- a/src/Dodge/Initialisation.hs +++ b/src/Dodge/Initialisation.hs @@ -54,7 +54,7 @@ initialWorld = defaultWorld } testStringInit :: World -> [String] --testStringInit _ = [] -testStringInit w = [show $ newSounds w] +testStringInit w = [show . length $ newSounds w] --testStringInit w = (show . _crPos $ _creatures w IM.! 0) -- : (map show . _grBound . last $ sortOn _grName grs) -- ++ closeRooms diff --git a/src/Dodge/SoundLogic/LoadSound.hs b/src/Dodge/SoundLogic/LoadSound.hs index d8aee1369..6db55cf26 100644 --- a/src/Dodge/SoundLogic/LoadSound.hs +++ b/src/Dodge/SoundLogic/LoadSound.hs @@ -13,11 +13,11 @@ loadSounds = do putdownSound' <- Mix.load "./data/sound/whiteNoiseFadeOut.wav" fireSound' <- Mix.load "./data/sound/fire1.wav" grenadeBang' <- Mix.load "./data/sound/grenade.wav" - tapQuiet' <- Mix.load "./data/sound/tapQuiet.wav" - twoStep' <- Mix.load "./data/sound/twoStep.wav" - healSound' <- Mix.load "./data/sound/heal.wav" - doorSound' <- Mix.load "./data/sound/slideDoor.wav" - twoStepSlow' <- Mix.load "./data/sound/twoStepSlow.wav" + tapQuiet' <- Mix.load "./data/sound/tapQuiet.wav" + twoStep' <- Mix.load "./data/sound/twoStep.wav" + healSound' <- Mix.load "./data/sound/heal.wav" + doorSound' <- Mix.load "./data/sound/slideDoor.wav" + twoStepSlow' <- Mix.load "./data/sound/twoStepSlow.wav" knifeSound' <- Mix.load "./data/sound/knife.wav" buzzSound' <- Mix.load "./data/sound/buzz.wav" hitSound' <- Mix.load "./data/sound/hit1.wav" @@ -46,7 +46,7 @@ loadSounds = do glass2' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A2.wav" glass3' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A3.wav" glass4' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A4.wav" - foamSpray' <- Mix.load "./data/sound/foamSprayLoop.wav" + foamSpray <- Mix.load "./data/sound/foamSprayLoop.wav" foamSprayFadeOut <- Mix.load "./data/sound/foamSprayFadeOut.wav" sineRaisePitchOneSec <- Mix.load "./data/sound/sineRaisePitchOneSec.wav" sineRaisePitchTwoSec <- Mix.load "./data/sound/sineRaisePitchTwoSec.wav" @@ -93,7 +93,7 @@ loadSounds = do , glass2' , glass3' , glass4' --40 - , foamSpray' + , foamSpray , foamSprayFadeOut , sineRaisePitchOneSec , sineRaisePitchTwoSec