31 lines
770 B
Haskell
31 lines
770 B
Haskell
{-# LANGUAGE TupleSections #-}
|
|
{- Bullet update. -}
|
|
module Dodge.Particle.Bullet.Update
|
|
( mvBullet
|
|
) where
|
|
import Dodge.Data
|
|
--import Dodge.Base
|
|
import Dodge.WorldEvent.ThingsHit
|
|
--import Picture
|
|
import Geometry
|
|
--import Geometry.Vector3D
|
|
|
|
import Data.Bifunctor
|
|
import Control.Lens
|
|
{-
|
|
Update for a generic bullet.
|
|
-}
|
|
mvBullet :: World -> Particle -> (World, Maybe Particle)
|
|
mvBullet w bt
|
|
| t <= 0 || magV (_btVel' bt) < 1 = wAnd Nothing
|
|
| otherwise = second (fmap dodrag) $ hiteff bt (thingsHitExceptCr mcr p (p +.+ vel) w) w
|
|
where
|
|
dodrag = btVel' %~ (drag *.*)
|
|
drag = _btDrag bt
|
|
wAnd = (w,)
|
|
mcr = _btPassThrough' bt
|
|
(p:_) = _btTrail' bt
|
|
vel = _btVel' bt
|
|
hiteff = _btHitEffect' bt
|
|
t = _btTimer' bt
|