Continue bullet refactor

This commit is contained in:
2022-07-16 22:02:01 +01:00
parent 301946ff8f
commit c9f7f39f22
12 changed files with 31 additions and 51 deletions
+3 -3
View File
@@ -6,12 +6,12 @@ import Control.Lens
dampField :: Magnet -> Bullet -> Bullet
dampField mg pt = case pt of
Bullet{} | dist (head $ _buTrail pt) (_mgPos mg) < 100 -> pt & buVel *~ 0.5
Bullet{} | dist (_buPos pt) (_mgPos mg) < 100 -> pt & buVel *~ 0.5
_ -> pt
curveLeftField :: Magnet -> Bullet -> Bullet
curveLeftField mg pt = case pt of
Bullet{} | dist (head $ _buTrail pt) (_mgPos mg) < 500 -> pt & buVel %~ rotateV 0.2
Bullet{} | dist (_buPos pt) (_mgPos mg) < 500 -> pt & buVel %~ rotateV 0.2
_ -> pt
curveAroundField :: Float -> Float -> Magnet -> Bullet -> Bullet
@@ -20,7 +20,7 @@ curveAroundField minrad maxrad mg pt = case pt of
where
thedist = dist btpos mgpos
mgpos = _mgPos mg
btpos = head $ _buTrail pt
btpos = _buPos 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) )