Continue bullet refactor
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
module Dodge.Particle.Bullet.Draw
|
||||
( drawBul
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Picture
|
||||
|
||||
import Linear
|
||||
|
||||
drawBul :: Bullet -> Picture
|
||||
drawBul pt = setLayer BloomNoZWrite
|
||||
. setDepth 20
|
||||
. color (V4 200 200 200 2)
|
||||
$ thickLine (_buWidth pt) [_buOldPos pt, _buPos pt]
|
||||
@@ -1,64 +0,0 @@
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
{- Bullet update. -}
|
||||
module Dodge.Particle.Bullet.Update
|
||||
( mvBullet
|
||||
, mvBulletSlow
|
||||
, mvSpark
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Movement.Turn
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
--import Picture
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
import Data.Bifunctor
|
||||
{- Update for a generic bullet. -}
|
||||
mvBullet :: World -> Bullet -> (World, Maybe Bullet)
|
||||
mvBullet w bt'
|
||||
| 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 = case _buTrajectory bt of
|
||||
BasicBulletTrajectory -> buVel .*.*~ drag
|
||||
MagnetTrajectory tpos -> buVel .+.+~ 5 *.* normalizeV (tpos -.- _buPos bt)
|
||||
FlechetteTrajectory tpos -> buVel %~ vecTurnTo 0.2 (_buPos bt) tpos
|
||||
BezierTrajectory spos tpos xpos ->
|
||||
let bf tm = bQuadToF (spos,xpos,tpos) $ (100 - tm) * 0.05
|
||||
in buVel .~ bf (fromIntegral $ _buTimer bt - 1) -.- bf (fromIntegral $ _buTimer bt)
|
||||
drag = _buDrag bt
|
||||
p = _buPos bt
|
||||
vel = _buVel bt
|
||||
hiteff = _buHitEff bt
|
||||
t = _buTimer bt
|
||||
|
||||
mvBulletSlow :: Float -> World -> Bullet -> (World, Maybe Bullet)
|
||||
mvBulletSlow x w bt'
|
||||
| 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)
|
||||
. (buState .~ NormalBulletState)
|
||||
drag = _buDrag bt
|
||||
p = _buPos bt
|
||||
vel = x *.* _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 = _ptDrag bt
|
||||
(p:_) = _ptTrail bt
|
||||
vel = _ptVel bt
|
||||
hiteff = _ptHitEff bt
|
||||
t = _ptTimer bt
|
||||
@@ -1,78 +0,0 @@
|
||||
module Dodge.Particle.Spark
|
||||
( colSpark
|
||||
, colSparkRandDir
|
||||
, createBarrelSpark
|
||||
, randColDirTimeSpark
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Particle.HitEffect.ExpireAndDamage
|
||||
import Dodge.Particle.Damage
|
||||
--import Dodge.Particle.Bullet.HitEffect
|
||||
import Dodge.Particle.Bullet.Update
|
||||
--import Dodge.WorldEvent.HitEffect
|
||||
import Color
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
import Control.Monad.State
|
||||
import System.Random
|
||||
--import Control.Lens
|
||||
-- TODO remove/simplify this function
|
||||
createBarrelSpark :: Point2 -> Float -> Int -> Int -> World -> World
|
||||
createBarrelSpark pos dir time colid = instantParticles .:~ PtSpark
|
||||
{ _ptUpdate = mvSpark
|
||||
, _ptVel = rotateV dir (V2 5 0)
|
||||
, _ptDrag = 0.9
|
||||
, _ptColor = numColor colid
|
||||
, _ptTrail = [pos]
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = expireAndDamage basicSparkDams
|
||||
}
|
||||
colSpark :: Int -> Color -> Point2 -> Float -> World -> World
|
||||
colSpark = colSparkRandDir 0.7
|
||||
|
||||
randColDirTimeSpark
|
||||
:: State StdGen Color
|
||||
-> State StdGen Float
|
||||
-> State StdGen Int
|
||||
-> Point2
|
||||
-> World
|
||||
-> World
|
||||
randColDirTimeSpark randcol randdir randtime pos w = w
|
||||
& instantParticles .:~ spark
|
||||
& randGen .~ g
|
||||
where
|
||||
((col,dir,time),g) = (`runState` _randGen w) $ do
|
||||
c <- randcol
|
||||
d <- randdir
|
||||
t <- randtime
|
||||
return (c,d,t)
|
||||
spark = PtSpark
|
||||
{ _ptUpdate = mvSpark
|
||||
, _ptDrag = 0.9
|
||||
, _ptVel = rotateV dir (V2 5 0)
|
||||
, _ptColor = col
|
||||
, _ptTrail = [pos]
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = expireAndDamage basicSparkDams
|
||||
}
|
||||
|
||||
colSparkRandDir :: Float -> Int -> Color -> Point2 -> Float -> World -> World
|
||||
colSparkRandDir randDir time col pos baseDir w = w
|
||||
& instantParticles .:~ spark
|
||||
& randGen .~ g
|
||||
where
|
||||
(a,g) = randomR (-randDir,randDir) $ _randGen w
|
||||
dir = a + baseDir
|
||||
spark = PtSpark
|
||||
{ _ptUpdate = mvSpark
|
||||
, _ptDrag = 0.9
|
||||
, _ptVel = rotateV dir (V2 5 0)
|
||||
, _ptColor = col
|
||||
, _ptTrail = [pos]
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = expireAndDamage basicSparkDams
|
||||
}
|
||||
@@ -3,22 +3,12 @@ module Dodge.Particle.TeslaArc
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Damage
|
||||
--import Dodge.WorldEvent.Damage
|
||||
--import Dodge.Base
|
||||
--import Dodge.Zone
|
||||
--import Dodge.Base.Collide
|
||||
import Dodge.Particle.Spark
|
||||
--import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.Spark
|
||||
import RandomHelp
|
||||
import Picture
|
||||
import Geometry
|
||||
--import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
|
||||
--import Data.Function (on)
|
||||
--import Data.List
|
||||
--import Data.Maybe
|
||||
|
||||
aTeslaArcAt :: Color -> [ArcStep] -> Particle
|
||||
aTeslaArcAt col thearc = PtTeslaArc
|
||||
{ _ptPoints = map (^. asPos) thearc
|
||||
|
||||
Reference in New Issue
Block a user