This commit is contained in:
2021-12-08 22:01:25 +00:00
parent a9139db0a8
commit eeda4f3e39
12 changed files with 98 additions and 36 deletions
+19
View File
@@ -8,3 +8,22 @@ dampField :: Magnet -> Particle -> Particle
dampField mg pt = case pt of
BulletPt{} | dist (head $ _btTrail' pt) (_mgPos mg) < 100 -> pt & btVel' *~ 0.5
_ -> pt
curveLeftField :: Magnet -> Particle -> Particle
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{} | dist btpos mgpos < 500 -> pt & btVel' %~ rotateToCircle
where
mgpos = _mgPos mg
btpos = head $ _btTrail' pt
rotateToCircle vel
| (isLHS mgpos btpos (btpos +.+ vel) && isRHS mgpos btpos (mgpos +.+ vNormal vel) )
|| (isRHS mgpos btpos (btpos +.+ vel) && isLHS mgpos btpos (mgpos +.+ vNormal vel) )
= rotateV rot vel
| otherwise = rotateV (negate rot) vel
rot = 0.5
_ -> pt