Continue tweaking sound
This commit is contained in:
+38
-30
@@ -6,8 +6,8 @@ This module allows us to talk to the "Sound" module.
|
||||
-}
|
||||
module Dodge.SoundLogic (
|
||||
-- * Manipulation of individual sounds
|
||||
soundOnceOrigin
|
||||
, soundFrom
|
||||
soundStart
|
||||
, soundContinue
|
||||
, soundFromGeneral
|
||||
, soundMultiFrom
|
||||
, stopSoundFrom
|
||||
@@ -22,7 +22,6 @@ import Dodge.Data.SoundOrigin
|
||||
import Sound.Data
|
||||
import Geometry.Data
|
||||
import Geometry.Vector
|
||||
import Dodge.SoundLogic.Synonyms
|
||||
import Dodge.SoundLogic.LoadSound
|
||||
|
||||
import Control.Lens
|
||||
@@ -41,41 +40,20 @@ pauseSound w = w
|
||||
resumeSound :: World -> World
|
||||
resumeSound w = w
|
||||
|
||||
{-| Play a sound once, with a given origin.
|
||||
For each origin only one sound will play at a time.
|
||||
-}
|
||||
soundOnceOrigin
|
||||
:: SoundID -- ^ 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 p w = w & sounds %~ M.insertWith (\ _ x -> x) so theSound
|
||||
where
|
||||
theSound = Sound
|
||||
{ _soundChunkID = sType
|
||||
, _soundTime = Nothing
|
||||
, _soundStatus = ToStart
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = p
|
||||
, _soundVolume = soundToVol sType
|
||||
}
|
||||
a = soundAngle p w
|
||||
|
||||
soundFrom
|
||||
:: SoundOrigin -- ^ \"Creator\" of sound
|
||||
soundWithStatus
|
||||
:: SoundStatus
|
||||
-> SoundOrigin -- ^ \"Creator\" of sound
|
||||
-> Point2 -- ^ Position of sound
|
||||
-> SoundID -- ^ ID of sound to be played
|
||||
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
|
||||
-> World
|
||||
-> World
|
||||
soundFrom so pos sType mtime w = over sounds (M.insertWith f so sound) w
|
||||
soundWithStatus status so pos sType mtime w = over sounds (M.insertWith f so sound) w
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundChunkID = sType
|
||||
, _soundTime = mtime
|
||||
, _soundStatus = ToStart
|
||||
, _soundStatus = status
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = pos
|
||||
@@ -84,6 +62,23 @@ soundFrom so pos sType mtime w = over sounds (M.insertWith f so sound) w
|
||||
f _ s = s {_soundTime = mtime }
|
||||
a = soundAngle pos w
|
||||
|
||||
soundStart
|
||||
:: SoundOrigin -- ^ \"Creator\" of sound
|
||||
-> Point2 -- ^ Position of sound
|
||||
-> SoundID -- ^ ID of sound to be played
|
||||
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
|
||||
-> World
|
||||
-> World
|
||||
soundStart = soundWithStatus ToStart
|
||||
soundContinue
|
||||
:: SoundOrigin -- ^ \"Creator\" of sound
|
||||
-> Point2 -- ^ Position of sound
|
||||
-> SoundID -- ^ ID of sound to be played
|
||||
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
|
||||
-> World
|
||||
-> World
|
||||
soundContinue = soundWithStatus ToContinueStart
|
||||
|
||||
soundFromGeneral
|
||||
:: SoundOrigin -- ^ \"Creator\" of sound
|
||||
-> (World -> Point2) -- ^ Position of sound
|
||||
@@ -130,8 +125,21 @@ soundMultiFrom
|
||||
-> World
|
||||
-> World
|
||||
soundMultiFrom [] _ _ _ w = w
|
||||
soundMultiFrom [so] pos sType mtime w
|
||||
= over sounds (M.insert so sound) w
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundChunkID = sType
|
||||
, _soundTime = mtime
|
||||
, _soundStatus = ToStart
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = pos
|
||||
, _soundVolume = soundToVol sType
|
||||
}
|
||||
a = soundAngle pos w
|
||||
soundMultiFrom (so:sos) pos sType mtime w
|
||||
| so `M.member` _sounds w = soundMultiFrom sos pos sType mtime w
|
||||
| so `M.member` _playingSounds w = soundMultiFrom sos pos sType mtime w
|
||||
| otherwise = over sounds (M.insert so sound) w
|
||||
where
|
||||
sound = Sound
|
||||
|
||||
Reference in New Issue
Block a user