This commit is contained in:
2022-07-10 12:51:20 +01:00
parent 23022d85a1
commit 7a1dbbb3f9
13 changed files with 35 additions and 198 deletions
+5 -93
View File
@@ -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. -}