From 9dadea2c3631224d68cd1445079e0b0e068fefef Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 15 Dec 2021 17:47:41 +0000 Subject: [PATCH] Fix bug in intersectCircSeg --- src/Dodge/Particle/Bullet/HitEffect.hs | 3 +-- src/Dodge/Particle/Spark.hs | 8 ++++---- src/Dodge/Wall/Damage.hs | 2 +- src/Geometry/Intersect.hs | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Dodge/Particle/Bullet/HitEffect.hs b/src/Dodge/Particle/Bullet/HitEffect.hs index d57be16c6..800391a0a 100644 --- a/src/Dodge/Particle/Bullet/HitEffect.hs +++ b/src/Dodge/Particle/Bullet/HitEffect.hs @@ -71,14 +71,13 @@ bulPenCr' bt p cr w ++ ) $ bulletHitSound ep - $ over worldEvents (addPiercer . ) + $ over instantParticles (piercer :) w where (d1,_) = randomR (-0.7,0.7) $ _randGen w cid = _crID cr sp = head $ _btTrail' bt ep = sp +.+ _ptVel bt - addPiercer = over particles (piercer :) piercer = (aGenBulAt (Just cid) p (_ptVel bt) (_btDrag bt) (_btHitEffect' bt) (_btWidth' bt) ) {_btTimer' = _btTimer' bt - 1} diff --git a/src/Dodge/Particle/Spark.hs b/src/Dodge/Particle/Spark.hs index 9e8ff3a38..77b1c684e 100644 --- a/src/Dodge/Particle/Spark.hs +++ b/src/Dodge/Particle/Spark.hs @@ -1,6 +1,6 @@ module Dodge.Particle.Spark ( colSpark - , colSpark' + , colSparkRandDir , createBarrelSpark ) where @@ -34,9 +34,9 @@ createBarrelSpark pos dir maycid time colid = instantParticles .:~ BulletPt sp = head (_btTrail' bt) ep = sp +.+ _ptVel bt colSpark :: Int -> Color -> Point2 -> Float -> World -> World -colSpark = colSpark' 0.7 -colSpark' :: Float -> Int -> Color -> Point2 -> Float -> World -> World -colSpark' randDir time col pos baseDir w = w +colSpark = colSparkRandDir 0.7 +colSparkRandDir :: Float -> Int -> Color -> Point2 -> Float -> World -> World +colSparkRandDir randDir time col pos baseDir w = w & instantParticles .:~ spark & randGen .~ g where diff --git a/src/Dodge/Wall/Damage.hs b/src/Dodge/Wall/Damage.hs index a7a7dbb55..751465836 100644 --- a/src/Dodge/Wall/Damage.hs +++ b/src/Dodge/Wall/Damage.hs @@ -24,7 +24,7 @@ damageWall dt wl = case _wlStructure wl of wallEff :: DamageType -> Wall -> World -> World wallEff dt wl = case dt of Lasering _ sp p _ -> colSpark 8 lSparkCol (outTo sp p) (reflDirWall sp p wl) - Piercing _ sp p _ -> colSpark' 0.2 8 pSparkCol (outTo sp p) (reflDirWall sp p wl) + Piercing _ sp p _ -> colSparkRandDir 0.2 8 pSparkCol (outTo sp p) (reflDirWall sp p wl) . wlDustAt wl (outTo sp p) Blunt _ sp p _ -> wlDustAt wl (outTo sp p) Explosive _ _ -> id diff --git a/src/Geometry/Intersect.hs b/src/Geometry/Intersect.hs index 3171680a1..129fba24c 100644 --- a/src/Geometry/Intersect.hs +++ b/src/Geometry/Intersect.hs @@ -259,7 +259,7 @@ inSegArea a b c = param >= 0 && param <= dotV (b -.- a) (b -.- a) intersectCircSeg :: Point2 -> Float -> Point2 -> Point2 -> [Point2] intersectCircSeg c r a b | y < 0 = [] - | otherwise = nub $ filter (inSegArea a b) [ d -.- v, d +.+ c ] + | otherwise = nub $ filter (inSegArea a b) [ d -.- v, d +.+ v ] where d = closestPointOnLine a b c x = dist d c