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=41) uniform sampler2DArray normalSampler;
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()
{
fCol = texture(diffuseSampler,gTexCoords);
+5 -2
View File
@@ -10,8 +10,7 @@ out vec3 gTexCoords;
float isLHS (vec2 startV, vec2 testV)
{ return sign( -startV.x * testV.y + startV.y * testV.x); }
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 p2xy = gl_in[0].gl_Position.zw;
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
@@ -25,18 +24,22 @@ void main()
gPos = p1;
gl_Position = vec4(theMat * p1);
gTexCoords = vec3 (0,0,tcoordz);
gAng = vTexAng[0].y;
EmitVertex();
gPos = p3;
gl_Position = vec4(theMat * p3);
gTexCoords = vec3 (0,2,tcoordz);
gAng = vTexAng[0].y;
EmitVertex();
gPos = p2;
gl_Position = vec4(theMat * p2);
gTexCoords = vec3 (tcoordx,0,tcoordz);
gAng = vTexAng[0].y;
EmitVertex();
gPos = p4;
gl_Position = vec4(theMat * p4);
gTexCoords = vec3 (tcoordx,2,tcoordz);
gAng = vTexAng[0].y;
EmitVertex();
EndPrimitive();
}
+21 -1
View File
@@ -2,6 +2,12 @@ module Dodge.Creature.Update (
updateCreature,
) where
import Picture.Base
import LensHelp
import Geometry
import Dodge.SoundLogic
import Dodge.Creature.Radius
import Geometry.Polygon
import Control.Lens
import Dodge.Creature.YourControl
import Dodge.Creature.State
@@ -9,9 +15,10 @@ import Dodge.Barreloid
import Dodge.Data.World
import Dodge.Humanoid
import Dodge.Lampoid
import qualified Data.List as List
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)
. crUpdate yourControl cr
LampCrit{} -> updateLampoid cr
@@ -19,6 +26,19 @@ updateCreature cr = case _crType cr of
AvatarDead -> id
_ -> 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 PulseStatus {_pulseRate = pr, _pulseProgress = pp}
| pp >= pr = PulseStatus pr 0
+2
View File
@@ -37,6 +37,8 @@ import qualified IntMapHelp as IM
data Creature = Creature
{ _crPos :: Point2
, _crOldPos :: Point2
, _crZ :: Float
, _crZVel :: Float
, _crDir :: Float
, _crMvDir :: Float
, _crMvAim :: Float
+1
View File
@@ -16,6 +16,7 @@ data SoundOrigin
| OnceSound
| CrSound Int
| CrMouth Int
| CrChasm Int
| CrWeaponSound Int Int
| CrWeaponFailSound Int
| MachineSound Int
+2
View File
@@ -14,6 +14,8 @@ defaultCreature =
Creature
{ _crPos = V2 0 0
, _crOldPos = V2 0 0
, _crZ = 0
, _crZVel = 0
, _crDir = 0
, _crMvDir = 0
, _crMvAim = 0
+5
View File
@@ -185,10 +185,15 @@ doDrawing' win pdata u = do
-- draw chasm shader blocking floor
glUseProgram (pdata ^. chasmShader . shaderUINT)
glBindVertexArray $ pdata ^. chasmShader . shaderVAO . vaoName
-- glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
glDrawBuffer GL_NONE
glDrawArrays
(_unPrimitiveMode $ pdata ^. chasmShader . shaderPrimitive)
0
(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
glUseProgram (pdata ^. floorShader . shaderUINT)
glBindVertexArray $ pdata ^. floorShader . shaderVAO . vaoName
+9 -4
View File
@@ -31,15 +31,20 @@ worldSPic cfig u =
<> foldup floorItemSPic (filtOn _flItPos (_unNIntMap . _floorItems))
<> foldup btSPic (filtOn _btPos _buttons)
<> foldup (mcSPic (u ^. uvWorld . cWorld . lWorld)) (filtOn _mcPos _machines)
-- <> foldMap' drawChasm (u ^. uvWorld . cWorld . chasms)
<> foldMap' drawChasm (u ^. uvWorld . cWorld . chasms)
where
w = _uvWorld u
foldup = foldMap'
filtOn f g = IM.filter (pointIsClose . f) (g (_lWorld (_cWorld w)))
pointIsClose = cullPoint cfig w
--drawChasm :: [Point2] -> SPic
--drawChasm = noShape . color green . setDepth 2 . polygon
drawChasm :: [Point2] -> SPic
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 pb =
@@ -50,7 +55,7 @@ drawPulseBall pb =
$ circleSolidCol green white 10
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
BarrelCrit{} -> barrelShape
LampCrit{_lampHeight = h} -> lampCrSPic h
+1 -1
View File
@@ -125,5 +125,5 @@ roomPillars pillarsize w h wn hn = do
where
pilw = ((w - 40 * (fromIntegral wn + 1)) / fromIntegral wn) - 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)
@@ -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
import Sound.Data
soundToVol :: SoundID -> Float
@@ -124,27 +124,28 @@ soundToVol v = case _getSoundID v of
118 -> 100
119 -> 300
120 -> 1000
121 -> 200
122 -> 100
123 -> 200
124 -> 1000
125 -> 2000
126 -> 200
127 -> 1000
128 -> 100
129 -> 200
130 -> 500
131 -> 100
132 -> 2000
133 -> 200
134 -> 300
135 -> 1000
136 -> 2000
121 -> 50
122 -> 200
123 -> 100
124 -> 200
125 -> 1000
126 -> 2000
127 -> 200
128 -> 1000
129 -> 100
130 -> 200
131 -> 500
132 -> 100
133 -> 2000
134 -> 200
135 -> 300
136 -> 1000
137 -> 2000
138 -> 250
139 -> 200
140 -> 100
141 -> 200
138 -> 2000
139 -> 250
140 -> 200
141 -> 100
142 -> 200
_ -> 50
soundToOnomato :: SoundID -> String
soundToOnomato v = case _getSoundID v of
@@ -269,27 +270,28 @@ soundToOnomato v = case _getSoundID v of
118 -> "HNH"
119 -> "BWAH"
120 -> "CRUNK"
121 -> "SQWLTCH"
122 -> "DRR"
123 -> "WHH"
124 -> "TRNKL"
125 -> "BRAP"
126 -> "WHR"
127 -> "BLPCHCH"
128 -> "SKLE"
129 -> "ZMM"
130 -> "WRRR"
131 -> "FWUMP"
132 -> "BRAHCHCH"
133 -> "TING"
134 -> "WHRR"
135 -> "BWMP"
136 -> "BRPBRPBRP"
137 -> "WE-OH"
138 -> "WHRHH"
139 -> "THCK"
140 -> "FHP"
141 -> "QWLPH"
121 -> "FHFH"
122 -> "SQWLTCH"
123 -> "DRR"
124 -> "WHH"
125 -> "TRNKL"
126 -> "BRAP"
127 -> "WHR"
128 -> "BLPCHCH"
129 -> "SKLE"
130 -> "ZMM"
131 -> "WRRR"
132 -> "FWUMP"
133 -> "BRAHCHCH"
134 -> "TING"
135 -> "WHRR"
136 -> "BWMP"
137 -> "BRPBRPBRP"
138 -> "WE-OH"
139 -> "WHRHH"
140 -> "THCK"
141 -> "FHP"
142 -> "QWLPH"
_ -> error "unitialised sound"
soundPathList :: [String]
soundPathList =
@@ -414,6 +416,7 @@ soundPathList =
, "grunt.HNH.100.wav"
, "sineRaisePitchOneSec.BWAH.300.wav"
, "metal2.CRUNK.1000.wav"
, "debris.FHFH.50.wav"
, "gut5.SQWLTCH.200.wav"
, "slideDoor.DRR.100.wav"
, "whirdown2.WHH.200.wav"
@@ -678,45 +681,47 @@ sineRaisePitchOneSecS :: SoundID
sineRaisePitchOneSecS = SoundID 119
metal2S :: SoundID
metal2S = SoundID 120
debrisS :: SoundID
debrisS = SoundID 121
gut5S :: SoundID
gut5S = SoundID 121
gut5S = SoundID 122
slideDoorS :: SoundID
slideDoorS = SoundID 122
slideDoorS = SoundID 123
whirdown2S :: SoundID
whirdown2S = SoundID 123
whirdown2S = SoundID 124
metal6S :: SoundID
metal6S = SoundID 124
metal6S = SoundID 125
autoGunS :: SoundID
autoGunS = SoundID 125
autoGunS = SoundID 126
whirdownSmall1S :: SoundID
whirdownSmall1S = SoundID 126
whirdownSmall1S = SoundID 127
oldMachineBootS :: SoundID
oldMachineBootS = SoundID 127
oldMachineBootS = SoundID 128
blood6S :: SoundID
blood6S = SoundID 128
blood6S = SoundID 129
buzzS :: SoundID
buzzS = SoundID 129
buzzS = SoundID 130
fireLoudS :: SoundID
fireLoudS = SoundID 130
fireLoudS = SoundID 131
tap4S :: SoundID
tap4S = SoundID 131
tap4S = SoundID 132
shotgunS :: SoundID
shotgunS = SoundID 132
shotgunS = SoundID 133
ting5S :: SoundID
ting5S = SoundID 133
ting5S = SoundID 134
whirS :: SoundID
whirS = SoundID 134
whirS = SoundID 135
sawtoothFailS :: SoundID
sawtoothFailS = SoundID 135
sawtoothFailS = SoundID 136
miniS :: SoundID
miniS = SoundID 136
miniS = SoundID 137
seagullWhistleS :: SoundID
seagullWhistleS = SoundID 137
seagullWhistleS = SoundID 138
whirdownS :: SoundID
whirdownS = SoundID 138
whirdownS = SoundID 139
connectItemS :: SoundID
connectItemS = SoundID 139
connectItemS = SoundID 140
whiteNoiseFadeInS :: SoundID
whiteNoiseFadeInS = SoundID 140
whiteNoiseFadeInS = SoundID 141
gut1S :: SoundID
gut1S = SoundID 141
gut1S = SoundID 142
+1 -1
View File
@@ -880,7 +880,7 @@ dustSpringVel a v b
radDist = 10
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
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 _ [] = 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 ::
-- | point to order around
Point2 ->
+277 -264
View File
File diff suppressed because it is too large Load Diff