From e1a9327c068d2572072c54878df582fa594a3ee6 Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 9 Dec 2021 17:33:59 +0000 Subject: [PATCH] Tweak basic curvearound magnet --- src/Dodge/Item/Equipment.hs | 2 +- src/Dodge/Magnet.hs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Dodge/Item/Equipment.hs b/src/Dodge/Item/Equipment.hs index 91c84deb9..709958ca2 100644 --- a/src/Dodge/Item/Equipment.hs +++ b/src/Dodge/Item/Equipment.hs @@ -33,7 +33,7 @@ useMagShield cr invid w = w & magnets . at mgid ?~ themagnet {_mgID = mgid ,_mgUpdate = Just . (mgUpdate .~ const Nothing) ,_mgPos = _crPos cr - ,_mgField = curveAroundField + ,_mgField = curveAroundField 50 200 } mgid = case it ^? itAttachment . itMInt . _Just of Just mgid' -> mgid' diff --git a/src/Dodge/Magnet.hs b/src/Dodge/Magnet.hs index f3eb61d88..b02a3ba1d 100644 --- a/src/Dodge/Magnet.hs +++ b/src/Dodge/Magnet.hs @@ -14,9 +14,9 @@ curveLeftField mg pt = case pt of BulletPt{} | dist (head $ _btTrail' pt) (_mgPos mg) < 500 -> pt & btVel' %~ rotateV 0.2 _ -> pt -curveAroundField :: Magnet -> Particle -> Particle -curveAroundField mg pt = case pt of - BulletPt{} | thedist < 200 -> pt & btVel' %~ rotateToCircle +curveAroundField :: Float -> Float -> Magnet -> Particle -> Particle +curveAroundField minrad maxrad mg pt = case pt of + BulletPt{} | thedist < maxrad -> pt & btVel' %~ rotateToCircle where thedist = dist btpos mgpos mgpos = _mgPos mg @@ -26,6 +26,6 @@ curveAroundField mg pt = case pt of || (isRHS mgpos btpos (btpos +.+ vel) && isLHS mgpos btpos (mgpos +.+ vNormal vel) ) = rotateV rot vel | otherwise = rotateV (negate rot) vel - rot | thedist < 100 = 0.5 - | otherwise = 0.5 - ((thedist - 100) / 200) + rot | thedist < minrad = 0.5 + | otherwise = 0.5 * ((maxrad - thedist) / (maxrad - minrad) ) ** 2 _ -> pt