Add sound effects to example analyser

This commit is contained in:
2022-03-22 10:53:01 +00:00
parent c0383dbd8a
commit 4cd7cf4edd
10 changed files with 236 additions and 197 deletions
Binary file not shown.
+24 -12
View File
@@ -754,19 +754,30 @@ data Block = Block
}
data BlockMaterial = WoodBlock | DirtBlock | StoneBlock | GlassBlock | MetalBlock
data Machine = Machine
{ _mcID :: Int
, _mcWallIDs :: IS.IntSet
, _mcUpdate :: Machine -> World -> World
, _mcDraw :: Machine -> SPic
, _mcPos :: Point2
, _mcDir :: Float
, _mcHP :: Int
, _mcSensorAmount :: Int
, _mcSensorToggle :: Bool
, _mcDamage :: [Damage]
, _mcLSs :: [Int]
, _mcType :: MachineType
{ _mcID :: Int
, _mcWallIDs :: IS.IntSet
, _mcUpdate :: Machine -> World -> World
, _mcDraw :: Machine -> SPic
, _mcPos :: Point2
, _mcDir :: Float
, _mcHP :: Int
, _mcSensor :: Sensor
, _mcDamage :: [Damage]
, _mcLSs :: [Int]
, _mcType :: MachineType
}
data Sensor = NoSensor
| SensorToggleAmount
{ _sensToggle :: Bool
, _sensAmount :: Int
}
| SensorCloseToggle
{ _sensCloseToggle :: CloseToggle
, _sensToggle :: Bool
}
deriving (Eq,Ord)
data CloseToggle = NotClose | IsClose
deriving (Eq,Ord)
data MachineType
= StaticMachine
| Turret
@@ -1037,3 +1048,4 @@ makeLenses ''TerminalParams
makeLenses ''TerminalLine
makeLenses ''ItemValue
makeLenses ''ScreenLayer
makeLenses ''Sensor
+1
View File
@@ -7,6 +7,7 @@ data SoundOrigin = InventorySound
| CrMouth Int
| CrWeaponSound Int Int
| MachineSound Int
| MachineAltSound Int
| TerminalSound
| WallSound Int
| CrReloadSound Int
+1 -2
View File
@@ -227,8 +227,7 @@ defaultMachine = Machine
, _mcPos = V2 0 0
, _mcDir = 0
, _mcHP = 1000
, _mcSensorAmount = 0
, _mcSensorToggle = False
, _mcSensor = NoSensor
, _mcDamage = []
, _mcLSs = []
, _mcType = StaticMachine
+21 -8
View File
@@ -15,6 +15,7 @@ import Dodge.Default
--import Dodge.Room.RoadBlock
import Dodge.Placement.Instance
import Dodge.Placement.Shift
import Dodge.SoundLogic
--import Dodge.Default.Room
--import Dodge.Item.Weapon.BulletGuns
--import Dodge.Item.Weapon.Utility
@@ -66,11 +67,11 @@ analyser' starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \t
, _termTitle = "ANALYSER"
}
)
(\mc -> upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_mcSensorToggle mc))
(\mc -> upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
)
simpleline str = TerminalLineDisplay {_tlPause = 0, _tlString = const (str,white)}
testline' mcid = TerminalLineDisplay 0 (testline mcid)
testline mcid w = case w ^? machines . ix mcid . mcSensorToggle of
testline mcid w = case w ^? machines . ix mcid . mcSensor . sensToggle of
Just True -> (sucs,green)
_ -> (fails,red)
updatebuttonname = plType . putButton . btText .~ "ANALYSER"
@@ -88,8 +89,9 @@ analyser starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \tp
Just $ psPtCont psmc
(PutMachine aquamarine (reverse $ square 10) defaultMachine
{ _mcDraw = const . noPic . colorSH aquamarine . upperPrismPoly 25 $ square 10
, _mcUpdate = \mc -> (triggers . ix (fromJust $ _plMID tp) .~ const (_mcSensorToggle mc))
, _mcUpdate = \mc -> (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
. upf mc
, _mcSensor = SensorCloseToggle NotClose False
}
) $ \anmc -> Just
$ plSpot .~ shiftRelativeToPS (V2 20 0) (_plSpot anmc)
@@ -104,15 +106,26 @@ analyser starts sucs fails afters upf pslight psmc = extTrigLitPos pslight $ \tp
where
simpleline str = TerminalLineDisplay {_tlPause = 0, _tlString = const (str,white)}
testline' mcid = TerminalLineDisplay 0 (testline mcid)
testline mcid w = case w ^? machines . ix mcid . mcSensorToggle of
testline mcid w = case w ^? machines . ix mcid . mcSensor . sensToggle of
Just True -> (sucs,green)
_ -> (fails,red)
updatebuttontext = plType . putButton . btText .~ "ANALYSER"
testYourHealth :: Int -> Machine -> World -> World
testYourHealth hp mc w
| _crHP ycr >= hp && dist (_crPos ycr) (_mcPos mc) < 40
= w & machines . ix (_mcID mc) . mcSensorToggle .~ True
| otherwise = w
testYourHealth hp mc w = case (_sensCloseToggle sens
, _sensToggle sens
, _crHP ycr >= hp
, dist (_crPos ycr) (_mcPos mc) < 40) of
(_,True,_,_) -> w
(_,False,True,True) -> w
& machines . ix (_mcID mc) . mcSensor . sensToggle .~ True
& playsound dededaS
& machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ IsClose
(NotClose,_,False,True) -> w & playsound dededumS
& machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ IsClose
(_,_,_,False) -> w & machines . ix (_mcID mc) . mcSensor . sensCloseToggle .~ NotClose
_ -> w
where
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
ycr = you w
sens = _mcSensor mc
+3 -2
View File
@@ -26,6 +26,7 @@ damageSensor dt wdth upf ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1)
$ \gw -> (,) gw $ PutMachine yellow (reverse $ square wdth) defaultMachine
{ _mcDraw = sensorSPic wdth $ _sensorCoding (_gParams gw) M.! dt
, _mcUpdate = \mc -> upf mc . sensorUpdate dt mc
, _mcSensor = SensorToggleAmount False 0
, _mcLSs = [lsid]
}
@@ -36,10 +37,10 @@ sensorUpdate :: DamageType -> Machine -> World -> World
sensorUpdate damF mc w = w & machines . ix mcid %~ upmc
& lightSources . ix lsid %~ upls
where
upmc = ( mcSensorAmount %~ \x' -> min 1000 (max 0 (x' - 5 + newSense)) )
upmc = ( mcSensor . sensAmount %~ \x' -> min 1000 (max 0 (x' - 5 + newSense)) )
. ( mcHP -~ sum dam )
. (mcDamage .~ [])
x = _mcSensorAmount mc
x = _sensAmount $ _mcSensor mc
mcid = _mcID mc
lsid = head (_mcLSs mc)
(senseData,dam) = partitionEithers $ map (damageUsing damF) $ _mcDamage mc
+1
View File
@@ -29,6 +29,7 @@ putTerminal' col mcf = ps0PushPS (PutButton thebutton)
{ _mcDraw = noPic . colorSH col . terminalShape
, _mcHP = 100
, _mcUpdate = mcf (fromJust $ _plMID pl)
, _mcSensor = SensorCloseToggle NotClose False
})
$ const Nothing
where
+4 -2
View File
@@ -15,6 +15,7 @@ import Dodge.Placement.Instance
import Dodge.Placement.Instance.Analyser
import Dodge.Default.Room
import Dodge.Item.Consumable
import Dodge.Machine
--import Dodge.Item.Weapon.Utility
--import Dodge.LevelGen.Data
--import Geometry.Data
@@ -24,6 +25,7 @@ import Color
import Shape
import LensHelp
import Dodge.RandomHelp
import Dodge.SoundLogic
import qualified Data.Set as S
import Data.Maybe
@@ -54,7 +56,7 @@ lasSensLightAboveDoor wth ps = extTrigLitPos
(atFstLnkOutShiftBy (\(p,a) -> (p +.+ rotateV a (V2 18.5 (-2.5)), a)))
( \tp -> Just $ lightSensor wth (upf $ fromJust $ _plMID tp) ps )
where
upf trid mc w | _mcSensorAmount mc > 900 = w & triggers . ix trid .~ const True
upf trid mc w | _sensAmount (_mcSensor mc) > 900 = w & triggers . ix trid .~ const True
| otherwise = w
lightSensByDoor :: Int -> Room -> Room
@@ -79,7 +81,7 @@ healthAnalyserByDoor = analyserByDoor
"PASSED"
"REQUIRES HEALTH AT LEAST 1100"
(replicate 3 "")
(testYourHealth 1100)
(machineAddSound fridgeHumS $ testYourHealth 1100)
analyserByDoor :: [String] -> String -> String -> [String]
-> (Machine -> World -> World) -> Int -> Room -> Room
+1 -1
View File
@@ -56,7 +56,7 @@ sensAboveDoor sensetype wth ps = extTrigLitPos
(atFstLnkOutShiftBy (\(p,a) -> (p +.+ rotateV a (V2 18.5 (-2.5)), a)))
( \tp -> Just $ damageSensor sensetype wth (upf $ fromJust $ _plMID tp) ps )
where
upf trid mc w | _mcSensorAmount mc > 900 = w & triggers . ix trid .~ const True
upf trid mc w | _sensAmount (_mcSensor mc) > 900 = w & triggers . ix trid .~ const True
| otherwise = w
sensInsideDoor :: DamageType -> Int -> Room -> Room
+180 -170
View File
@@ -1,4 +1,4 @@
-- generated at 2022-03-15 09:41:05.616513405 UTC
-- generated at 2022-03-22 10:04:11.692663796 UTC
module Dodge.SoundLogic.ExternallyGeneratedSounds where
import Sound.Data
soundToVol :: SoundID -> Float
@@ -11,64 +11,66 @@ soundToVol v = case _getSoundID v of
5 -> 5000
6 -> 5000
7 -> 3000
8 -> 3000
9 -> 4000
10 -> 5000
11 -> 10000
12 -> 8000
13 -> 8000
8 -> 5000
9 -> 3000
10 -> 4000
11 -> 5000
12 -> 5000
13 -> 10000
14 -> 8000
15 -> 8000
16 -> 10000
17 -> 3000
18 -> 4000
19 -> 5000
20 -> 5000
21 -> 20000
22 -> 4000
23 -> 10000
24 -> 8000
25 -> 4000
26 -> 2000
27 -> 6000
28 -> 500
29 -> 5000
30 -> 8000
31 -> 8000
16 -> 8000
17 -> 8000
18 -> 10000
19 -> 3000
20 -> 4000
21 -> 5000
22 -> 5000
23 -> 20000
24 -> 4000
25 -> 10000
26 -> 8000
27 -> 4000
28 -> 2000
29 -> 6000
30 -> 500
31 -> 5000
32 -> 8000
33 -> 5000
33 -> 8000
34 -> 8000
35 -> 4000
36 -> 3000
37 -> 8000
38 -> 2000
39 -> 10000
40 -> 5000
41 -> 2000
42 -> 3000
43 -> 5000
44 -> 10000
45 -> 12000
46 -> 5000
47 -> 10000
48 -> 12000
49 -> 2000
50 -> 3000
51 -> 8000
52 -> 5000
53 -> 2000
54 -> 3000
55 -> 10000
56 -> 500
35 -> 5000
36 -> 8000
37 -> 4000
38 -> 3000
39 -> 8000
40 -> 2000
41 -> 10000
42 -> 5000
43 -> 2000
44 -> 3000
45 -> 5000
46 -> 10000
47 -> 12000
48 -> 5000
49 -> 10000
50 -> 12000
51 -> 2000
52 -> 3000
53 -> 8000
54 -> 5000
55 -> 2000
56 -> 3000
57 -> 10000
58 -> 3000
59 -> 15000
60 -> 10000
61 -> 3000
62 -> 1000
63 -> 15000
64 -> 10000
65 -> 8000
58 -> 500
59 -> 10000
60 -> 3000
61 -> 15000
62 -> 10000
63 -> 3000
64 -> 1000
65 -> 15000
66 -> 10000
67 -> 8000
_ -> 50
soundToOnomato :: SoundID -> String
soundToOnomato v = case _getSoundID v of
@@ -80,64 +82,66 @@ soundToOnomato v = case _getSoundID v of
5 -> "UGGAUGGA"
6 -> "KRTNKL"
7 -> "DWAAH"
8 -> "BWAH"
9 -> "TIPTOP"
10 -> "TINKLE"
11 -> "TATATA"
12 -> "CRSK"
13 -> "CRNK"
14 -> "TAKH"
15 -> "CRUNK"
16 -> "SCREE"
17 -> "TNKTNKTNK"
18 -> "TIPTAP"
19 -> "WRR"
20 -> "HSS"
21 -> "BOOM"
22 -> "CLNK"
23 -> "BRAP"
24 -> "CRSNK"
25 -> "TAPP"
26 -> "BLIH"
27 -> "TAPTIP"
28 -> "CLICK"
29 -> "FWUMP"
30 -> "RINGGG"
31 -> "BRAP"
32 -> "CRUMPLE"
33 -> "TRINKL"
34 -> "TAK"
35 -> "SMACK"
36 -> "DRR"
37 -> "CRASH"
38 -> "SWSH"
39 -> "CRAKLE"
40 -> "CRTINK"
41 -> "FHP"
42 -> "CHPCHPCHP"
43 -> "BIPBIPBIP"
44 -> "CHUGUGUG"
45 -> "BRPBRPBRP"
46 -> "CHNKCHNKCHUNK"
47 -> "WRRR"
48 -> "BRDBRDBRD"
49 -> "PHF"
50 -> "BWAAH"
51 -> "BEP"
52 -> "HSSS"
53 -> "SHUHP"
54 -> "THUD"
55 -> "WHSSH"
56 -> "HMM"
57 -> "BRAHCHCH"
58 -> "TIP"
59 -> "BANGG"
60 -> "ZHM"
61 -> "TAP"
62 -> "BLPCHCH"
63 -> "BANG"
64 -> "CHUGUGUG"
65 -> "CRISH"
8 -> "DEDEDUM"
9 -> "BWAH"
10 -> "TIPTOP"
11 -> "DEDEDA"
12 -> "TINKLE"
13 -> "TATATA"
14 -> "CRSK"
15 -> "CRNK"
16 -> "TAKH"
17 -> "CRUNK"
18 -> "SCREE"
19 -> "TNKTNKTNK"
20 -> "TIPTAP"
21 -> "WRR"
22 -> "HSS"
23 -> "BOOM"
24 -> "CLNK"
25 -> "BRAP"
26 -> "CRSNK"
27 -> "TAPP"
28 -> "BLIH"
29 -> "TAPTIP"
30 -> "CLICK"
31 -> "FWUMP"
32 -> "RINGGG"
33 -> "BRAP"
34 -> "CRUMPLE"
35 -> "TRINKL"
36 -> "TAK"
37 -> "SMACK"
38 -> "DRR"
39 -> "CRASH"
40 -> "SWSH"
41 -> "CRAKLE"
42 -> "CRTINK"
43 -> "FHP"
44 -> "CHPCHPCHP"
45 -> "BIPBIPBIP"
46 -> "CHUGUGUG"
47 -> "BRPBRPBRP"
48 -> "CHNKCHNKCHUNK"
49 -> "WRRR"
50 -> "BRDBRDBRD"
51 -> "PHF"
52 -> "BWAAH"
53 -> "BEP"
54 -> "HSSS"
55 -> "SHUHP"
56 -> "THUD"
57 -> "WHSSH"
58 -> "HMM"
59 -> "BRAHCHCH"
60 -> "TIP"
61 -> "BANGG"
62 -> "ZHM"
63 -> "TAP"
64 -> "BLPCHCH"
65 -> "BANG"
66 -> "CHUGUGUG"
67 -> "CRISH"
_ -> error "unitialised sound"
soundPathList :: [String]
soundPathList =
@@ -149,8 +153,10 @@ soundPathList =
, "seagullBark.UGGAUGGA.5000.wav"
, "smallGlass2.KRTNKL.5000.wav"
, "skwareFadeTwoSec.DWAAH.3000.wav"
, "dededum.DEDEDUM.5000.wav"
, "sineRaisePitchOneSec.BWAH.3000.wav"
, "twoStepSlow.TIPTOP.4000.wav"
, "dededa.DEDEDA.5000.wav"
, "smallGlass4.TINKLE.5000.wav"
, "autoB.TATATA.10000.wav"
, "glassShat4.CRSK.8000.wav"
@@ -224,119 +230,123 @@ smallGlass2S :: SoundID
smallGlass2S = SoundID 6
skwareFadeTwoSecS :: SoundID
skwareFadeTwoSecS = SoundID 7
dededumS :: SoundID
dededumS = SoundID 8
sineRaisePitchOneSecS :: SoundID
sineRaisePitchOneSecS = SoundID 8
sineRaisePitchOneSecS = SoundID 9
twoStepSlowS :: SoundID
twoStepSlowS = SoundID 9
twoStepSlowS = SoundID 10
dededaS :: SoundID
dededaS = SoundID 11
smallGlass4S :: SoundID
smallGlass4S = SoundID 10
smallGlass4S = SoundID 12
autoBS :: SoundID
autoBS = SoundID 11
autoBS = SoundID 13
glassShat4S :: SoundID
glassShat4S = SoundID 12
glassShat4S = SoundID 14
glassShat3S :: SoundID
glassShat3S = SoundID 13
glassShat3S = SoundID 15
tap2S :: SoundID
tap2S = SoundID 14
tap2S = SoundID 16
impact2S :: SoundID
impact2S = SoundID 15
impact2S = SoundID 17
tone440sawtoothS :: SoundID
tone440sawtoothS = SoundID 16
tone440sawtoothS = SoundID 18
reloadS :: SoundID
reloadS = SoundID 17
reloadS = SoundID 19
twoStepS :: SoundID
twoStepS = SoundID 18
twoStepS = SoundID 20
fireS :: SoundID
fireS = SoundID 19
fireS = SoundID 21
foamSprayFadeOutS :: SoundID
foamSprayFadeOutS = SoundID 20
foamSprayFadeOutS = SoundID 22
explosionS :: SoundID
explosionS = SoundID 21
explosionS = SoundID 23
tapQuietS :: SoundID
tapQuietS = SoundID 22
tapQuietS = SoundID 24
autoGunS :: SoundID
autoGunS = SoundID 23
autoGunS = SoundID 25
glassShat1S :: SoundID
glassShat1S = SoundID 24
glassShat1S = SoundID 26
foot3S :: SoundID
foot3S = SoundID 25
foot3S = SoundID 27
healS :: SoundID
healS = SoundID 26
healS = SoundID 28
twoStep1S :: SoundID
twoStep1S = SoundID 27
twoStep1S = SoundID 29
click1S :: SoundID
click1S = SoundID 28
click1S = SoundID 30
tap4S :: SoundID
tap4S = SoundID 29
tap4S = SoundID 31
tinitusS :: SoundID
tinitusS = SoundID 30
tinitusS = SoundID 32
tap3S :: SoundID
tap3S = SoundID 31
tap3S = SoundID 33
impact3S :: SoundID
impact3S = SoundID 32
impact3S = SoundID 34
smallGlass1S :: SoundID
smallGlass1S = SoundID 33
smallGlass1S = SoundID 35
tap1S :: SoundID
tap1S = SoundID 34
tap1S = SoundID 36
hit1S :: SoundID
hit1S = SoundID 35
hit1S = SoundID 37
slideDoorS :: SoundID
slideDoorS = SoundID 36
slideDoorS = SoundID 38
impact1S :: SoundID
impact1S = SoundID 37
impact1S = SoundID 39
knifeS :: SoundID
knifeS = SoundID 38
knifeS = SoundID 40
elecCrackleS :: SoundID
elecCrackleS = SoundID 39
elecCrackleS = SoundID 41
smallGlass3S :: SoundID
smallGlass3S = SoundID 40
smallGlass3S = SoundID 42
whiteNoiseFadeInS :: SoundID
whiteNoiseFadeInS = SoundID 41
whiteNoiseFadeInS = SoundID 43
reload1S :: SoundID
reload1S = SoundID 42
reload1S = SoundID 44
computerBeepingS :: SoundID
computerBeepingS = SoundID 43
computerBeepingS = SoundID 45
seagullChatter1S :: SoundID
seagullChatter1S = SoundID 44
seagullChatter1S = SoundID 46
miniS :: SoundID
miniS = SoundID 45
miniS = SoundID 47
crankSlowS :: SoundID
crankSlowS = SoundID 46
crankSlowS = SoundID 48
fireLoudS :: SoundID
fireLoudS = SoundID 47
fireLoudS = SoundID 49
mini1S :: SoundID
mini1S = SoundID 48
mini1S = SoundID 50
whiteNoiseFadeOutS :: SoundID
whiteNoiseFadeOutS = SoundID 49
whiteNoiseFadeOutS = SoundID 51
sineRaisePitchTwoSecS :: SoundID
sineRaisePitchTwoSecS = SoundID 50
sineRaisePitchTwoSecS = SoundID 52
tone440S :: SoundID
tone440S = SoundID 51
tone440S = SoundID 53
foamSprayLoopS :: SoundID
foamSprayLoopS = SoundID 52
foamSprayLoopS = SoundID 54
pickUpS :: SoundID
pickUpS = SoundID 53
pickUpS = SoundID 55
hitS :: SoundID
hitS = SoundID 54
hitS = SoundID 56
missileLaunchS :: SoundID
missileLaunchS = SoundID 55
missileLaunchS = SoundID 57
fridgeHumS :: SoundID
fridgeHumS = SoundID 56
fridgeHumS = SoundID 58
shotgunS :: SoundID
shotgunS = SoundID 57
shotgunS = SoundID 59
foot1S :: SoundID
foot1S = SoundID 58
foot1S = SoundID 60
bangEchoS :: SoundID
bangEchoS = SoundID 59
bangEchoS = SoundID 61
teleS :: SoundID
teleS = SoundID 60
teleS = SoundID 62
foot2S :: SoundID
foot2S = SoundID 61
foot2S = SoundID 63
oldMachineBootS :: SoundID
oldMachineBootS = SoundID 62
oldMachineBootS = SoundID 64
bangS :: SoundID
bangS = SoundID 63
bangS = SoundID 65
seagullChatterS :: SoundID
seagullChatterS = SoundID 64
seagullChatterS = SoundID 66
impact4S :: SoundID
impact4S = SoundID 65
impact4S = SoundID 67