Move sparks into dedicated datatype
This commit is contained in:
@@ -15,14 +15,6 @@ simpleDam' dt amount bt p = [ Damage dt amount sp p ep NoDamageEffect ]
|
||||
bulVel = _buVel bt
|
||||
ep = sp +.+ bulVel
|
||||
|
||||
|
||||
basicSparkDams :: Particle -> Point2 -> [Damage]
|
||||
basicSparkDams bt p = [ Damage SPARKING 1 sp p ep NoDamageEffect ]
|
||||
where
|
||||
sp = head $ _ptTrail bt
|
||||
bulVel = _ptVel bt
|
||||
ep = sp +.+ bulVel
|
||||
|
||||
hvBulDams :: [Damage]
|
||||
hvBulDams =
|
||||
[ Damage PIERCING 25 0 0 0 NoDamageEffect
|
||||
|
||||
@@ -10,7 +10,6 @@ drawParticle pt = case pt of
|
||||
PtStaticBall {} -> drawStaticBall pt
|
||||
PtIncBall {} -> drawFlameletZ pt
|
||||
PtInvShockwave {} -> drawInverseShockwave pt
|
||||
PtSpark {} -> drawSpark pt
|
||||
PtTeslaArc {} -> drawTeslaArc pt
|
||||
PtTargetLaser {} -> drawTargetLaser pt
|
||||
LaserParticle {} -> drawLaser pt
|
||||
@@ -124,12 +123,6 @@ drawInverseShockwave pt
|
||||
rad = r - 0.1 * r * fromIntegral (10 - t)
|
||||
thickness = fromIntegral (10 - t) **2 * rad / 40
|
||||
|
||||
drawSpark :: Particle -> Picture
|
||||
drawSpark pt = setLayer BloomNoZWrite
|
||||
. setDepth 20
|
||||
. color (_ptColor pt)
|
||||
$ thickLine (_ptWidth pt) (take 2 $ _ptTrail pt)
|
||||
|
||||
drawTeslaArc :: Particle -> Picture
|
||||
drawTeslaArc pt = setLayer BloomNoZWrite $ pictures
|
||||
[ setDepth 20.5 $ color (brightX 2 1 $ _ptColor pt) $ thickLine 3 ps
|
||||
|
||||
@@ -15,8 +15,7 @@ expireAndDamage :: (Particle -> Point2 -> [Damage])
|
||||
-> (World, Maybe Particle)
|
||||
expireAndDamage fdm bt things w = case runIdentity $ S.head_ things of
|
||||
Nothing -> (w, mvPt' bt)
|
||||
Just x -> (doDamages fdm x bt w, destroyAt (fst x) bt)
|
||||
|
||||
Just x -> (doDamages fdm x bt w, destroyAt bt)
|
||||
|
||||
doDamages :: (Particle -> Point2 -> [Damage])
|
||||
-> (Point2, Either Creature Wall)
|
||||
|
||||
@@ -28,8 +28,7 @@ moveTeslaArc thearc w pt
|
||||
where
|
||||
rcol = brightX 100 1.5 <$> takeOne [white,azure,blue,cyan]
|
||||
rdir = state (randomR (-0.7,0.7)) <&> (+ ld)
|
||||
rtime = state $ randomR (5,8)
|
||||
makeaspark = randColDirTimeSpark rcol rdir rtime lp
|
||||
makeaspark = randColDirTimeSpark rcol rdir lp
|
||||
makesparks = makeaspark . makeaspark . makeaspark
|
||||
(lp,ld) = case last thearc of
|
||||
ArcStep lp' ld' Nothing -> (lp',ld')
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
module Dodge.Particle.Update where
|
||||
import Dodge.Data
|
||||
import LensHelp
|
||||
import Geometry
|
||||
|
||||
mvPt' :: Particle -> Maybe Particle
|
||||
mvPt' pt = Just $ pt
|
||||
& ptTrail %~ f
|
||||
& ptTimer -~ 1
|
||||
where
|
||||
f trl = head trl +.+ _ptVel pt : trl
|
||||
|
||||
destroyAt :: Point2 -> Particle -> Maybe Particle
|
||||
destroyAt hitp pt = Just $ pt
|
||||
destroyAt :: Particle -> Maybe Particle
|
||||
destroyAt pt = Just $ pt
|
||||
& ptUpdate .~ killParticleUpdate
|
||||
& ptTrail .:~ hitp
|
||||
& ptTimer %~ (min 3 . subtract 1)
|
||||
|
||||
killParticleUpdate :: World -> Particle -> (World,Maybe Particle)
|
||||
@@ -21,5 +16,4 @@ killParticleUpdate w pt
|
||||
| _ptTimer pt <= 0 = (w,Nothing)
|
||||
| otherwise = (w
|
||||
, Just $ pt & ptTimer -~ 1
|
||||
& ptTrail %~ (\(x:xs) -> x:x:xs)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user