Move bullets into own data type
This commit is contained in:
+7
-7
@@ -4,23 +4,23 @@ import Geometry
|
||||
|
||||
import Control.Lens
|
||||
|
||||
dampField :: Magnet -> Particle -> Particle
|
||||
dampField :: Magnet -> Bullet -> Bullet
|
||||
dampField mg pt = case pt of
|
||||
BulletPt{} | dist (head $ _ptTrail pt) (_mgPos mg) < 100 -> pt & ptVel *~ 0.5
|
||||
Bullet{} | dist (head $ _buTrail pt) (_mgPos mg) < 100 -> pt & buVel *~ 0.5
|
||||
_ -> pt
|
||||
|
||||
curveLeftField :: Magnet -> Particle -> Particle
|
||||
curveLeftField :: Magnet -> Bullet -> Bullet
|
||||
curveLeftField mg pt = case pt of
|
||||
BulletPt{} | dist (head $ _ptTrail pt) (_mgPos mg) < 500 -> pt & ptVel %~ rotateV 0.2
|
||||
Bullet{} | dist (head $ _buTrail pt) (_mgPos mg) < 500 -> pt & buVel %~ rotateV 0.2
|
||||
_ -> pt
|
||||
|
||||
curveAroundField :: Float -> Float -> Magnet -> Particle -> Particle
|
||||
curveAroundField :: Float -> Float -> Magnet -> Bullet -> Bullet
|
||||
curveAroundField minrad maxrad mg pt = case pt of
|
||||
BulletPt{} | thedist < maxrad -> pt & ptVel %~ rotateToCircle
|
||||
Bullet{} | thedist < maxrad -> pt & buVel %~ rotateToCircle
|
||||
where
|
||||
thedist = dist btpos mgpos
|
||||
mgpos = _mgPos mg
|
||||
btpos = head $ _ptTrail pt
|
||||
btpos = head $ _buTrail 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) )
|
||||
|
||||
Reference in New Issue
Block a user