Add sound queue when on chasm edge

This commit is contained in:
2025-07-30 14:01:56 +01:00
parent d1346b855f
commit 7110ddb7a6
16 changed files with 401 additions and 341 deletions
Binary file not shown.
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -3
View File
@@ -8,9 +8,7 @@ in float gAng;
layout (binding=40) uniform sampler2DArray diffuseSampler; layout (binding=40) uniform sampler2DArray diffuseSampler;
layout (binding=41) uniform sampler2DArray normalSampler; layout (binding=41) uniform sampler2DArray normalSampler;
vec2 rotateV2 (float a, vec2 v) vec2 rotateV2 (float a, vec2 v)
{ { return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a)); }
return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a));
}
void main() void main()
{ {
fCol = texture(diffuseSampler,gTexCoords); fCol = texture(diffuseSampler,gTexCoords);
+5 -2
View File
@@ -10,8 +10,7 @@ out vec3 gTexCoords;
float isLHS (vec2 startV, vec2 testV) float isLHS (vec2 startV, vec2 testV)
{ return sign( -startV.x * testV.y + startV.y * testV.x); } { return sign( -startV.x * testV.y + startV.y * testV.x); }
void main() void main()
{ gAng = vTexAng[0].y; { float tcoordz = vTexAng[0].x;
float tcoordz = vTexAng[0].x;
vec2 p1xy = gl_in[0].gl_Position.xy; vec2 p1xy = gl_in[0].gl_Position.xy;
vec2 p2xy = gl_in[0].gl_Position.zw; vec2 p2xy = gl_in[0].gl_Position.zw;
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1); vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
@@ -25,18 +24,22 @@ void main()
gPos = p1; gPos = p1;
gl_Position = vec4(theMat * p1); gl_Position = vec4(theMat * p1);
gTexCoords = vec3 (0,0,tcoordz); gTexCoords = vec3 (0,0,tcoordz);
gAng = vTexAng[0].y;
EmitVertex(); EmitVertex();
gPos = p3; gPos = p3;
gl_Position = vec4(theMat * p3); gl_Position = vec4(theMat * p3);
gTexCoords = vec3 (0,2,tcoordz); gTexCoords = vec3 (0,2,tcoordz);
gAng = vTexAng[0].y;
EmitVertex(); EmitVertex();
gPos = p2; gPos = p2;
gl_Position = vec4(theMat * p2); gl_Position = vec4(theMat * p2);
gTexCoords = vec3 (tcoordx,0,tcoordz); gTexCoords = vec3 (tcoordx,0,tcoordz);
gAng = vTexAng[0].y;
EmitVertex(); EmitVertex();
gPos = p4; gPos = p4;
gl_Position = vec4(theMat * p4); gl_Position = vec4(theMat * p4);
gTexCoords = vec3 (tcoordx,2,tcoordz); gTexCoords = vec3 (tcoordx,2,tcoordz);
gAng = vTexAng[0].y;
EmitVertex(); EmitVertex();
EndPrimitive(); EndPrimitive();
} }
+21 -1
View File
@@ -2,6 +2,12 @@ module Dodge.Creature.Update (
updateCreature, updateCreature,
) where ) where
import Picture.Base
import LensHelp
import Geometry
import Dodge.SoundLogic
import Dodge.Creature.Radius
import Geometry.Polygon
import Control.Lens import Control.Lens
import Dodge.Creature.YourControl import Dodge.Creature.YourControl
import Dodge.Creature.State import Dodge.Creature.State
@@ -9,9 +15,10 @@ import Dodge.Barreloid
import Dodge.Data.World import Dodge.Data.World
import Dodge.Humanoid import Dodge.Humanoid
import Dodge.Lampoid import Dodge.Lampoid
import qualified Data.List as List
updateCreature :: Creature -> World -> World updateCreature :: Creature -> World -> World
updateCreature cr = case _crType cr of updateCreature cr = chasmTest cr . case _crType cr of
Avatar{} -> (cWorld . lWorld . creatures . ix 0 . crType . avatarPulse %~ updatePulse) Avatar{} -> (cWorld . lWorld . creatures . ix 0 . crType . avatarPulse %~ updatePulse)
. crUpdate yourControl cr . crUpdate yourControl cr
LampCrit{} -> updateLampoid cr LampCrit{} -> updateLampoid cr
@@ -19,6 +26,19 @@ updateCreature cr = case _crType cr of
AvatarDead -> id AvatarDead -> id
_ -> updateHumanoid cr _ -> updateHumanoid cr
chasmTest :: Creature -> World -> World
chasmTest cr w
| _crZVel cr < 0 = w & cWorld . lWorld . creatures . ix (_crID cr) . crZVel -~ 1
& cWorld . lWorld . creatures . ix (_crID cr) . crZ +~ (_crZVel cr)
| Just (x,y) <- List.find g (foldMap loopPairs $ w ^. cWorld . chasms) = w
& soundContinue (CrChasm (_crID cr)) (_crPos cr) debrisS (Just 100)
& cWorld . lWorld . creatures . ix (_crID cr) . crPos -~ normalizeV (vNormal (x-y))
| any f (w ^. cWorld . chasms) = w & cWorld . lWorld . creatures . ix (_crID cr) . crZVel -~ 1
| otherwise = w
where
g = uncurry $ circOnSeg (_crPos cr) (crRad $ cr ^. crType)
f = circInPolygon (_crPos cr) (crRad $ cr ^. crType)
updatePulse :: Pulse -> Pulse updatePulse :: Pulse -> Pulse
updatePulse PulseStatus {_pulseRate = pr, _pulseProgress = pp} updatePulse PulseStatus {_pulseRate = pr, _pulseProgress = pp}
| pp >= pr = PulseStatus pr 0 | pp >= pr = PulseStatus pr 0
+2
View File
@@ -37,6 +37,8 @@ import qualified IntMapHelp as IM
data Creature = Creature data Creature = Creature
{ _crPos :: Point2 { _crPos :: Point2
, _crOldPos :: Point2 , _crOldPos :: Point2
, _crZ :: Float
, _crZVel :: Float
, _crDir :: Float , _crDir :: Float
, _crMvDir :: Float , _crMvDir :: Float
, _crMvAim :: Float , _crMvAim :: Float
+1
View File
@@ -16,6 +16,7 @@ data SoundOrigin
| OnceSound | OnceSound
| CrSound Int | CrSound Int
| CrMouth Int | CrMouth Int
| CrChasm Int
| CrWeaponSound Int Int | CrWeaponSound Int Int
| CrWeaponFailSound Int | CrWeaponFailSound Int
| MachineSound Int | MachineSound Int
+2
View File
@@ -14,6 +14,8 @@ defaultCreature =
Creature Creature
{ _crPos = V2 0 0 { _crPos = V2 0 0
, _crOldPos = V2 0 0 , _crOldPos = V2 0 0
, _crZ = 0
, _crZVel = 0
, _crDir = 0 , _crDir = 0
, _crMvDir = 0 , _crMvDir = 0
, _crMvAim = 0 , _crMvAim = 0
+5
View File
@@ -185,10 +185,15 @@ doDrawing' win pdata u = do
-- draw chasm shader blocking floor -- draw chasm shader blocking floor
glUseProgram (pdata ^. chasmShader . shaderUINT) glUseProgram (pdata ^. chasmShader . shaderUINT)
glBindVertexArray $ pdata ^. chasmShader . shaderVAO . vaoName glBindVertexArray $ pdata ^. chasmShader . shaderVAO . vaoName
-- glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
glDrawBuffer GL_NONE
glDrawArrays glDrawArrays
(_unPrimitiveMode $ pdata ^. chasmShader . shaderPrimitive) (_unPrimitiveMode $ pdata ^. chasmShader . shaderPrimitive)
0 0
(fromIntegral nchs) (fromIntegral nchs)
-- glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2]
$ \ptr -> glDrawBuffers 3 ptr
--draw floor onto base buffer --draw floor onto base buffer
glUseProgram (pdata ^. floorShader . shaderUINT) glUseProgram (pdata ^. floorShader . shaderUINT)
glBindVertexArray $ pdata ^. floorShader . shaderVAO . vaoName glBindVertexArray $ pdata ^. floorShader . shaderVAO . vaoName
+9 -4
View File
@@ -31,15 +31,20 @@ worldSPic cfig u =
<> foldup floorItemSPic (filtOn _flItPos (_unNIntMap . _floorItems)) <> foldup floorItemSPic (filtOn _flItPos (_unNIntMap . _floorItems))
<> foldup btSPic (filtOn _btPos _buttons) <> foldup btSPic (filtOn _btPos _buttons)
<> foldup (mcSPic (u ^. uvWorld . cWorld . lWorld)) (filtOn _mcPos _machines) <> foldup (mcSPic (u ^. uvWorld . cWorld . lWorld)) (filtOn _mcPos _machines)
-- <> foldMap' drawChasm (u ^. uvWorld . cWorld . chasms) <> foldMap' drawChasm (u ^. uvWorld . cWorld . chasms)
where where
w = _uvWorld u w = _uvWorld u
foldup = foldMap' foldup = foldMap'
filtOn f g = IM.filter (pointIsClose . f) (g (_lWorld (_cWorld w))) filtOn f g = IM.filter (pointIsClose . f) (g (_lWorld (_cWorld w)))
pointIsClose = cullPoint cfig w pointIsClose = cullPoint cfig w
--drawChasm :: [Point2] -> SPic drawChasm :: [Point2] -> SPic
--drawChasm = noShape . color green . setDepth 2 . polygon drawChasm = foldMap (Prelude.uncurry drawCliff) . loopPairs
drawCliff :: Point2 -> Point2 -> SPic
drawCliff x y = noPic
. translateSHz (-500.01)
$ upperPrismPoly Large Important 500 [x,0.5 *(x+y) + normalizeV (vNormal (y - x)),y]
drawPulseBall :: PulseBall -> SPic drawPulseBall :: PulseBall -> SPic
drawPulseBall pb = drawPulseBall pb =
@@ -50,7 +55,7 @@ drawPulseBall pb =
$ circleSolidCol green white 10 $ circleSolidCol green white 10
drawCreature :: Creature -> SPic drawCreature :: Creature -> SPic
drawCreature cr = uncurryV translateSPxy (_crPos cr) . rotateSP (_crDir cr) $ drawCreature cr = translateSPz (_crZ cr) . uncurryV translateSPxy (_crPos cr) . rotateSP (_crDir cr) $
case cr ^. crType of case cr ^. crType of
BarrelCrit{} -> barrelShape BarrelCrit{} -> barrelShape
LampCrit{_lampHeight = h} -> lampCrSPic h LampCrit{_lampHeight = h} -> lampCrSPic h
+1 -1
View File
@@ -125,5 +125,5 @@ roomPillars pillarsize w h wn hn = do
where where
pilw = ((w - 40 * (fromIntegral wn + 1)) / fromIntegral wn) - pillarsize pilw = ((w - 40 * (fromIntegral wn + 1)) / fromIntegral wn) - pillarsize
pilh = ((h - 40 * (fromIntegral hn + 1)) / fromIntegral hn) - pillarsize pilh = ((h - 40 * (fromIntegral hn + 1)) / fromIntegral hn) - pillarsize
testchasm = Placement 0 (PS 0 0) (PutChasm (map (+V2 100 100) (square 50))) Nothing testchasm = Placement 0 (PS 0 0) (PutChasm (map (+V2 50 120) (rectWH 50 25))) Nothing
(\_ _ -> Nothing) (\_ _ -> Nothing)
@@ -1,4 +1,4 @@
-- generated at 2025-07-26 12:49:22.540764534 UTC -- generated at 2025-07-30 11:38:32.680040921 UTC
module Dodge.SoundLogic.ExternallyGeneratedSounds where module Dodge.SoundLogic.ExternallyGeneratedSounds where
import Sound.Data import Sound.Data
soundToVol :: SoundID -> Float soundToVol :: SoundID -> Float
@@ -124,27 +124,28 @@ soundToVol v = case _getSoundID v of
118 -> 100 118 -> 100
119 -> 300 119 -> 300
120 -> 1000 120 -> 1000
121 -> 200 121 -> 50
122 -> 100 122 -> 200
123 -> 200 123 -> 100
124 -> 1000 124 -> 200
125 -> 2000 125 -> 1000
126 -> 200 126 -> 2000
127 -> 1000 127 -> 200
128 -> 100 128 -> 1000
129 -> 200 129 -> 100
130 -> 500 130 -> 200
131 -> 100 131 -> 500
132 -> 2000 132 -> 100
133 -> 200 133 -> 2000
134 -> 300 134 -> 200
135 -> 1000 135 -> 300
136 -> 2000 136 -> 1000
137 -> 2000 137 -> 2000
138 -> 250 138 -> 2000
139 -> 200 139 -> 250
140 -> 100 140 -> 200
141 -> 200 141 -> 100
142 -> 200
_ -> 50 _ -> 50
soundToOnomato :: SoundID -> String soundToOnomato :: SoundID -> String
soundToOnomato v = case _getSoundID v of soundToOnomato v = case _getSoundID v of
@@ -269,27 +270,28 @@ soundToOnomato v = case _getSoundID v of
118 -> "HNH" 118 -> "HNH"
119 -> "BWAH" 119 -> "BWAH"
120 -> "CRUNK" 120 -> "CRUNK"
121 -> "SQWLTCH" 121 -> "FHFH"
122 -> "DRR" 122 -> "SQWLTCH"
123 -> "WHH" 123 -> "DRR"
124 -> "TRNKL" 124 -> "WHH"
125 -> "BRAP" 125 -> "TRNKL"
126 -> "WHR" 126 -> "BRAP"
127 -> "BLPCHCH" 127 -> "WHR"
128 -> "SKLE" 128 -> "BLPCHCH"
129 -> "ZMM" 129 -> "SKLE"
130 -> "WRRR" 130 -> "ZMM"
131 -> "FWUMP" 131 -> "WRRR"
132 -> "BRAHCHCH" 132 -> "FWUMP"
133 -> "TING" 133 -> "BRAHCHCH"
134 -> "WHRR" 134 -> "TING"
135 -> "BWMP" 135 -> "WHRR"
136 -> "BRPBRPBRP" 136 -> "BWMP"
137 -> "WE-OH" 137 -> "BRPBRPBRP"
138 -> "WHRHH" 138 -> "WE-OH"
139 -> "THCK" 139 -> "WHRHH"
140 -> "FHP" 140 -> "THCK"
141 -> "QWLPH" 141 -> "FHP"
142 -> "QWLPH"
_ -> error "unitialised sound" _ -> error "unitialised sound"
soundPathList :: [String] soundPathList :: [String]
soundPathList = soundPathList =
@@ -414,6 +416,7 @@ soundPathList =
, "grunt.HNH.100.wav" , "grunt.HNH.100.wav"
, "sineRaisePitchOneSec.BWAH.300.wav" , "sineRaisePitchOneSec.BWAH.300.wav"
, "metal2.CRUNK.1000.wav" , "metal2.CRUNK.1000.wav"
, "debris.FHFH.50.wav"
, "gut5.SQWLTCH.200.wav" , "gut5.SQWLTCH.200.wav"
, "slideDoor.DRR.100.wav" , "slideDoor.DRR.100.wav"
, "whirdown2.WHH.200.wav" , "whirdown2.WHH.200.wav"
@@ -678,45 +681,47 @@ sineRaisePitchOneSecS :: SoundID
sineRaisePitchOneSecS = SoundID 119 sineRaisePitchOneSecS = SoundID 119
metal2S :: SoundID metal2S :: SoundID
metal2S = SoundID 120 metal2S = SoundID 120
debrisS :: SoundID
debrisS = SoundID 121
gut5S :: SoundID gut5S :: SoundID
gut5S = SoundID 121 gut5S = SoundID 122
slideDoorS :: SoundID slideDoorS :: SoundID
slideDoorS = SoundID 122 slideDoorS = SoundID 123
whirdown2S :: SoundID whirdown2S :: SoundID
whirdown2S = SoundID 123 whirdown2S = SoundID 124
metal6S :: SoundID metal6S :: SoundID
metal6S = SoundID 124 metal6S = SoundID 125
autoGunS :: SoundID autoGunS :: SoundID
autoGunS = SoundID 125 autoGunS = SoundID 126
whirdownSmall1S :: SoundID whirdownSmall1S :: SoundID
whirdownSmall1S = SoundID 126 whirdownSmall1S = SoundID 127
oldMachineBootS :: SoundID oldMachineBootS :: SoundID
oldMachineBootS = SoundID 127 oldMachineBootS = SoundID 128
blood6S :: SoundID blood6S :: SoundID
blood6S = SoundID 128 blood6S = SoundID 129
buzzS :: SoundID buzzS :: SoundID
buzzS = SoundID 129 buzzS = SoundID 130
fireLoudS :: SoundID fireLoudS :: SoundID
fireLoudS = SoundID 130 fireLoudS = SoundID 131
tap4S :: SoundID tap4S :: SoundID
tap4S = SoundID 131 tap4S = SoundID 132
shotgunS :: SoundID shotgunS :: SoundID
shotgunS = SoundID 132 shotgunS = SoundID 133
ting5S :: SoundID ting5S :: SoundID
ting5S = SoundID 133 ting5S = SoundID 134
whirS :: SoundID whirS :: SoundID
whirS = SoundID 134 whirS = SoundID 135
sawtoothFailS :: SoundID sawtoothFailS :: SoundID
sawtoothFailS = SoundID 135 sawtoothFailS = SoundID 136
miniS :: SoundID miniS :: SoundID
miniS = SoundID 136 miniS = SoundID 137
seagullWhistleS :: SoundID seagullWhistleS :: SoundID
seagullWhistleS = SoundID 137 seagullWhistleS = SoundID 138
whirdownS :: SoundID whirdownS :: SoundID
whirdownS = SoundID 138 whirdownS = SoundID 139
connectItemS :: SoundID connectItemS :: SoundID
connectItemS = SoundID 139 connectItemS = SoundID 140
whiteNoiseFadeInS :: SoundID whiteNoiseFadeInS :: SoundID
whiteNoiseFadeInS = SoundID 140 whiteNoiseFadeInS = SoundID 141
gut1S :: SoundID gut1S :: SoundID
gut1S = SoundID 141 gut1S = SoundID 142
+1 -1
View File
@@ -880,7 +880,7 @@ dustSpringVel a v b
radDist = 10 radDist = 10
simpleCrSprings :: World -> World simpleCrSprings :: World -> World
simpleCrSprings w = IM.foldl' (flip crSpring) w $ w ^. cWorld . lWorld . creatures simpleCrSprings w = IM.foldl' (flip crSpring) w $ IM.filter (\cr -> _crZ cr >= 0) $ w ^. cWorld . lWorld . creatures
-- note that this may in rare cases not push creatures away from each other -- note that this may in rare cases not push creatures away from each other
crSpring :: Creature -> World -> World crSpring :: Creature -> World -> World
+6
View File
@@ -67,6 +67,12 @@ pointInPolygon :: Point2 -> [Point2] -> Bool
pointInPolygon !p (x : xs) = all (\l -> uncurry isLHS l p) $ zip (x : xs) (xs ++ [x]) pointInPolygon !p (x : xs) = all (\l -> uncurry isLHS l p) $ zip (x : xs) (xs ++ [x])
pointInPolygon _ [] = False pointInPolygon _ [] = False
circInPolygon :: Point2 -> Float -> [Point2] -> Bool
circInPolygon !p !r (x : xs) = all f $ zip (x : xs) (xs ++ [x])
where
f l = uncurry isLHS l (p - r *.* vNormal (normalizeV (uncurry (-.-) l)))
circInPolygon _ _ [] = False
orderPolygonAround :: orderPolygonAround ::
-- | point to order around -- | point to order around
Point2 -> Point2 ->
+277 -264
View File
File diff suppressed because it is too large Load Diff