Move bullets into own data type
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
{- Bullet update. -}
|
||||
module Dodge.Particle.Bullet.Update
|
||||
( mvBullet
|
||||
, mvSpark
|
||||
) where
|
||||
import Dodge.Data
|
||||
--import Dodge.Base
|
||||
@@ -12,15 +13,29 @@ import LensHelp
|
||||
|
||||
import Data.Bifunctor
|
||||
{- Update for a generic bullet. -}
|
||||
mvBullet :: World -> Particle -> (World, Maybe Particle)
|
||||
mvBullet :: World -> Bullet -> (World, Maybe Bullet)
|
||||
mvBullet w bt'
|
||||
| t <= 0 || magV (_ptVel bt) < 1 = (w,Nothing)
|
||||
| t <= 0 || magV (_buVel bt) < 1 = (w,Nothing)
|
||||
| otherwise = second (fmap dodrag) $
|
||||
hiteff bt (thingsHit p (p +.+ vel) w) w
|
||||
where
|
||||
bt = foldr (\mg b -> _mgField mg mg b) bt' $ _magnets w
|
||||
dodrag = buVel .*.*~ drag
|
||||
drag = _buDrag bt
|
||||
(p:_) = _buTrail bt
|
||||
vel = _buVel bt
|
||||
hiteff = _buHitEff bt
|
||||
t = _buTimer bt
|
||||
|
||||
mvSpark :: World -> Particle -> (World, Maybe Particle)
|
||||
mvSpark w bt'
|
||||
| t <= 0 || magV (_ptVel bt) < 1 = (w,Nothing)
|
||||
| otherwise = second (fmap dodrag) $
|
||||
hiteff bt (thingsHit p (p +.+ vel) w) w
|
||||
where
|
||||
bt = bt'
|
||||
dodrag = ptVel .*.*~ drag
|
||||
drag = _btDrag bt
|
||||
drag = _ptDrag bt
|
||||
(p:_) = _ptTrail bt
|
||||
vel = _ptVel bt
|
||||
hiteff = _ptHitEff bt
|
||||
|
||||
Reference in New Issue
Block a user