From 2bc30d0a6ba76d429eac504f2ad708f8c418b4ab Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 16 Jun 2022 12:40:27 +0100 Subject: [PATCH] Fix bug in randArc --- src/Dodge/Block/Debris.hs | 9 +++++---- src/Dodge/Item/Weapon/Shatter.hs | 2 +- src/RandomHelp.hs | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Dodge/Block/Debris.hs b/src/Dodge/Block/Debris.hs index 3812e76dc..4046ca5fc 100644 --- a/src/Dodge/Block/Debris.hs +++ b/src/Dodge/Block/Debris.hs @@ -19,17 +19,18 @@ makeBlockDebris :: Block -> World -> World makeBlockDebris bl = makeDebris (greyN 0.5) (_blMaterial bl) (_blPos bl) makeDebris :: Color -> BlockMaterial -> Point2 -> World -> World -makeDebris = makeDebrisDirected (2*pi) 0 +makeDebris = makeDebrisDirected 1 2 (2*pi) 0 -makeDebrisDirected :: Float -> Float -> Color -> BlockMaterial -> Point2 -> World -> World -makeDebrisDirected arcrad dir col bm p w = w +makeDebrisDirected :: Float -> Float + -> Float -> Float -> Color -> BlockMaterial -> Point2 -> World -> World +makeDebrisDirected mindist maxdist arcrad dir col bm p w = w & flip (foldr (plNew props pjID)) thedebris & randGen .~ newg & matDesSound bm p where (thedebris,newg) = runState (mapM f [35,55..95]) $ _randGen w f h = do - v <- rotateV (dir - arcrad/2) <$> randInArcStrip 2 3 arcrad + v <- rotateV (dir - arcrad/2) <$> randInArcStrip mindist maxdist arcrad q <- Q.vToQuat (V3 0 0 1) <$> randOnUnitSphere return $ someDebris & prPos .~ p diff --git a/src/Dodge/Item/Weapon/Shatter.hs b/src/Dodge/Item/Weapon/Shatter.hs index 15383638b..f467eccf0 100644 --- a/src/Dodge/Item/Weapon/Shatter.hs +++ b/src/Dodge/Item/Weapon/Shatter.hs @@ -61,5 +61,5 @@ shootShatter it cr w = maybe w (uncurry $ shatterWall w sp ep) $ collidePointWal shatterWall :: World -> Point2 -> Point2 -> Point2 -> Wall -> World shatterWall w sp ep p wl = w & makeDebris (_wlColor wl) StoneBlock p - & makeDebrisDirected (pi/2) (argV $ vNormal $ uncurry (-.-) $ _wlLine wl) (_wlColor wl) StoneBlock p + & makeDebrisDirected 1 2 (pi/2) (argV $ vNormal $ uncurry (-.-) $ _wlLine wl) (_wlColor wl) StoneBlock p & damageWall (Damage SHATTERING 1000 sp p ep NoDamageEffect) wl diff --git a/src/RandomHelp.hs b/src/RandomHelp.hs index 271ca8f9f..4c9f65757 100644 --- a/src/RandomHelp.hs +++ b/src/RandomHelp.hs @@ -66,13 +66,13 @@ randProb p = do return (p1 < p) randInCirc :: RandomGen g => Float -> State g Point2 -randInCirc = randInArc (2*pi) +randInCirc rad = randInArc rad (2*pi) randInArc :: RandomGen g => Float -> Float -> State g Point2 randInArc = randInArcStrip 0 randInArcStrip :: RandomGen g => Float -> Float -> Float -> State g Point2 -randInArcStrip minrad maxangle maxRad = do +randInArcStrip minrad maxRad maxangle = do rad <- state $ randomR (minrad,maxRad) ang <- state $ randomR (0,maxangle) return $ rad *.* unitVectorAtAngle ang