Cleanup
This commit is contained in:
@@ -26,9 +26,8 @@ import System.Random
|
||||
|
||||
muzFlareAt :: Color -> Point3 -> Float -> World -> World
|
||||
muzFlareAt col tranv dir w = w & instantParticles .:~ PtMuzFlare
|
||||
{ _ptDraw = const $ setLayer BloomNoZWrite . translate3 tranv $ theShape
|
||||
, _ptUpdate = ptSimpleTime 2
|
||||
, _ptPoly =
|
||||
{ _ptUpdate = ptSimpleTime 2
|
||||
, _ptPoly = map (rotateV dir)
|
||||
[ V2 0 0
|
||||
, V2 a (-b)
|
||||
, V2 c d
|
||||
@@ -37,18 +36,11 @@ muzFlareAt col tranv dir w = w & instantParticles .:~ PtMuzFlare
|
||||
, _ptTran3 = tranv
|
||||
}
|
||||
where
|
||||
theShape = rotate dir . color col $ polygon
|
||||
[ V2 0 0
|
||||
, V2 a (-b)
|
||||
, V2 c d
|
||||
]
|
||||
(a:b:c:d:_) = randomRs (2,20) (_randGen w)
|
||||
|
||||
flareCircleAt :: Color -> Float -> Point3 -> World -> World
|
||||
flareCircleAt col alphax tranv = instantParticles .:~ PtCircFlare
|
||||
{ _ptDraw = const . setLayer BloomNoZWrite . translate3 tranv
|
||||
$ circleSolidCol (withAlpha 0 0) (withAlpha alphax col) 50
|
||||
, _ptUpdate = ptSimpleTime 1
|
||||
{ _ptUpdate = ptSimpleTime 1
|
||||
, _ptColor = col
|
||||
, _ptAlpha = alphax
|
||||
, _ptTran3 = tranv
|
||||
|
||||
@@ -26,8 +26,7 @@ makeShockwaveAt
|
||||
-> World -- ^ Start world.
|
||||
-> World
|
||||
makeShockwaveAt is p rad dam push col = instantParticles .:~ Shockwave
|
||||
{ _ptDraw = drawShockwave
|
||||
, _ptUpdate = mvShockwave is
|
||||
{ _ptUpdate = mvShockwave is
|
||||
, _ptColor = col
|
||||
, _ptPos = p
|
||||
, _ptRad = rad
|
||||
@@ -88,8 +87,7 @@ inverseShockwaveAt
|
||||
-> World
|
||||
-> World
|
||||
inverseShockwaveAt p rad dam push = instantParticles .:~ Shockwave
|
||||
{ _ptDraw = drawInverseShockwave
|
||||
, _ptUpdate = moveInverseShockwave
|
||||
{ _ptUpdate = moveInverseShockwave
|
||||
, _ptColor = cyan
|
||||
, _ptPos = p
|
||||
, _ptRad = rad
|
||||
@@ -119,13 +117,3 @@ moveInverseShockwave w pt
|
||||
where
|
||||
cpos = _crPos cr
|
||||
|
||||
drawInverseShockwave :: Particle -> Picture
|
||||
drawInverseShockwave pt
|
||||
= setLayer BloomLayer $ setDepth 20 $ uncurryV translate p
|
||||
$ color cyan $ thickCircle rad thickness
|
||||
where
|
||||
p = _ptPos pt
|
||||
r = _ptRad pt
|
||||
t = _ptTimer pt
|
||||
rad = r - 0.1 * r * fromIntegral (10 - t)
|
||||
thickness = fromIntegral (10 - t) **2 * rad / 40
|
||||
|
||||
@@ -34,8 +34,7 @@ aFlameParticle
|
||||
-> Maybe Int -- ^ Creature id
|
||||
-> Particle
|
||||
aFlameParticle t pos vel maycid = PtFlame
|
||||
{ _ptDraw = drawFlame vel
|
||||
, _ptUpdate = moveFlame vel
|
||||
{ _ptUpdate = moveFlame vel
|
||||
, _ptVel = vel
|
||||
, _ptColor = red
|
||||
, _ptPos = pos
|
||||
@@ -46,36 +45,6 @@ aFlameParticle t pos vel maycid = PtFlame
|
||||
, _ptZ = 20
|
||||
, _ptOriginalVel = vel
|
||||
}
|
||||
drawFlame
|
||||
:: Point2 -- ^ Rotate direction
|
||||
-> Particle
|
||||
-> Picture
|
||||
drawFlame rotd pt = pictures
|
||||
[ glow
|
||||
, aPic BloomNoZWrite prot2 25 (V2 (scaleChange + 1) 2 ) $ V4 2 (-1) (-1) 0.5
|
||||
, aPic BloomNoZWrite prot 22 (V2 (scaleChange + 0.5) 1 ) $ V4 1 0.5 0 2
|
||||
, aPic BloomLayer prot3 20 (V2 scaleChange 0.5) $ V4 1 1 1 1
|
||||
]
|
||||
where
|
||||
ep = _ptPos pt
|
||||
aPic :: Layer -> (Point2 -> Point2) -> Float -> Point2 -> Color -> Picture
|
||||
aPic lay offset depth (V2 scalex scaley) col
|
||||
= setLayer lay
|
||||
. setDepth depth
|
||||
. uncurryV translate (offset ep)
|
||||
. rotate (pi * 0.5 + argV rotd)
|
||||
. scale scalex scaley
|
||||
. color col
|
||||
$ circleSolid 5
|
||||
glow = setLayer BloomNoZWrite $ setDepth 0.3 $ uncurryV translate ep
|
||||
$ circleSolidCol (withAlpha 0 orange) (withAlpha 0.02 orange) 50
|
||||
time = _ptTimer pt
|
||||
scaleChange
|
||||
| time < 80 = 3
|
||||
| otherwise = 3 - (fromIntegral time - 80) * 0.2
|
||||
prot p' = p' +.+ rotateV (fromIntegral time) (V2 0 1)
|
||||
prot2 p' = p' +.+ rotateV (negate $ fromIntegral time) (V2 0 1)
|
||||
prot3 p' = p' +.+ rotateV (2 + fromIntegral time * 0.1) (V2 0 2)
|
||||
{- TODO: add generalised area damage particles/hiteffects. -}
|
||||
moveFlame :: Point2 -- ^ Rotation direction
|
||||
-> World
|
||||
@@ -116,8 +85,7 @@ moveFlame rotd w pt
|
||||
|
||||
concBall :: Point2 -> State g Particle
|
||||
concBall p = return Shockwave
|
||||
{ _ptDraw = drawShockwave
|
||||
, _ptUpdate = mvShockwave []
|
||||
{ _ptUpdate = mvShockwave []
|
||||
, _ptColor = white
|
||||
, _ptPos = p
|
||||
, _ptRad = 15
|
||||
@@ -130,8 +98,7 @@ concBall p = return Shockwave
|
||||
|
||||
aStaticBall :: Point2 -> State g Particle
|
||||
aStaticBall p = return PtStaticBall
|
||||
{ _ptDraw = drawStaticBall
|
||||
, _ptUpdate = moveStaticBall
|
||||
{ _ptUpdate = moveStaticBall
|
||||
, _ptVel = 0
|
||||
, _ptColor = blue
|
||||
, _ptPos = p
|
||||
@@ -154,8 +121,7 @@ makeFlamelet
|
||||
makeFlamelet (V2 x y) z vel maycid size time w = w
|
||||
& randGen .~ g
|
||||
& instantParticles .:~ PtIncBall
|
||||
{ _ptDraw = drawFlameletZ rot
|
||||
, _ptUpdate = moveFlamelet
|
||||
{ _ptUpdate = moveFlamelet
|
||||
, _ptVel = vel
|
||||
, _ptColor = red
|
||||
, _ptPos = V2 x y
|
||||
@@ -184,15 +150,6 @@ makeFlamelet (V2 x y) z vel maycid size time w = w
|
||||
-- sp = _ptPos pt
|
||||
-- ep = sp +.+ _ptVel pt
|
||||
|
||||
drawStaticBall
|
||||
:: Particle
|
||||
-> Picture
|
||||
drawStaticBall pt = setLayer BloomNoZWrite
|
||||
. setDepth (_ptZ pt + 20)
|
||||
. uncurryV translate (_ptPos pt)
|
||||
$ circleSolidCol (_ptColor pt) (withAlpha 0.5 white) (_ptWidth pt+5)
|
||||
|
||||
|
||||
moveStaticBall :: World -> Particle -> (World, Maybe Particle)
|
||||
moveStaticBall = moveFlamelet
|
||||
|
||||
@@ -257,8 +214,7 @@ incBall :: RandomGen g => Point2 -> State g Particle
|
||||
incBall p = do
|
||||
rot <- state $ randomR (0,3)
|
||||
return PtIncBall
|
||||
{ _ptDraw = drawFlameletZ rot
|
||||
, _ptUpdate = moveFlamelet
|
||||
{ _ptUpdate = moveFlamelet
|
||||
, _ptVel = 0
|
||||
, _ptColor = red
|
||||
, _ptPos = p
|
||||
@@ -269,50 +225,6 @@ incBall p = do
|
||||
, _ptZ = 20
|
||||
, _ptRot = rot
|
||||
}
|
||||
drawFlameletZ
|
||||
:: Float -- ^ Rotation
|
||||
-> Particle
|
||||
-> Picture
|
||||
drawFlameletZ rot pt = pictures
|
||||
[ setLayer BloomLayer pic
|
||||
, setLayer BloomNoZWrite piu
|
||||
, setLayer BloomNoZWrite pi2
|
||||
]
|
||||
where
|
||||
z = _ptZ pt
|
||||
sp = _ptPos pt
|
||||
vel = _ptVel pt
|
||||
ep = sp +.+ vel
|
||||
size = _ptWidth pt
|
||||
siz2 = size + 0.2
|
||||
time = _ptTimer pt
|
||||
piu = setDepth (z + 25)
|
||||
. uncurryV translate ep
|
||||
. color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time)
|
||||
(V4 2 0 0 1) (V4 2 0 0 0)
|
||||
)
|
||||
. rotate (negate (rot - 0.1 * fromIntegral time))
|
||||
. scale s1 s1
|
||||
$ polygon (rectNSWE siz2 (-siz2) (-siz2) siz2)
|
||||
pi2 = setDepth (z + 25)
|
||||
. uncurryV translate ep
|
||||
. color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time)
|
||||
(V4 2 1 0 0.5) (V4 0 0 0 0)
|
||||
)
|
||||
. rotate (negate (rot + 0.2 * fromIntegral time))
|
||||
. scale s2 s2
|
||||
$ polygon (rectNSWE siz2 (-siz2) (-siz2) siz2)
|
||||
pic = setDepth (z + 20)
|
||||
. uncurryV translate ep
|
||||
. color (mixColors (fromIntegral (max 0 (time-2))) (10-fromIntegral time)
|
||||
(V4 1 1 1 3) (V4 1 0 0 1)
|
||||
)
|
||||
. rotate (negate ( 0.1 * fromIntegral time + rot))
|
||||
. scale (0.5* sc) (0.5 *sc)
|
||||
$ polygon $ map toV2 [(-size,-size),(size,-size),(size,size),(-size,size)]
|
||||
sc = (*) 2 $ log $ 1 + fromIntegral time / 20
|
||||
s1 = (*) 2 $ log $ 2 + fromIntegral time / 40
|
||||
s2 = 0.5 * (sc + s1)
|
||||
|
||||
{- Update of a flamelet.
|
||||
Applies movement and attaches damage to nearby creatures. -}
|
||||
|
||||
Reference in New Issue
Block a user