100 lines
3.0 KiB
Haskell
100 lines
3.0 KiB
Haskell
module Dodge.EnergyBall.Draw (drawEnergyBall) where
|
|
|
|
import Dodge.Data.EnergyBall
|
|
import Geometry
|
|
import Picture
|
|
|
|
drawEnergyBall :: EnergyBall -> Picture
|
|
drawEnergyBall eb = case _ebType eb of
|
|
FlameletBall x -> drawFlamelet x eb
|
|
IncendiaryBall -> drawFlamelet 5 eb
|
|
ElectricalBall{} -> drawStaticBall eb
|
|
ExplosiveBall -> drawExplosiveBall eb
|
|
FlashBall -> mempty
|
|
|
|
drawExplosiveBall :: EnergyBall -> Picture
|
|
drawExplosiveBall eb =
|
|
setLayer BloomLayer
|
|
-- . setDepth 20
|
|
-- . uncurryV translate (_ebPos eb)
|
|
. translate3 (_ebPos eb)
|
|
. color white
|
|
$ thickCircle r x
|
|
where
|
|
x = 1 + 3 * (1 - (1 - y ** 2))
|
|
r = 15 - (12 * y)
|
|
y = fromIntegral (_ebTimer eb - 10) / 10
|
|
|
|
drawStaticBall :: EnergyBall -> Picture
|
|
drawStaticBall pt =
|
|
setLayer BloomNoZWrite
|
|
-- . setDepth 20
|
|
-- -- . setDepth (_ebZ pt + 20)
|
|
-- . uncurryV translate (_ebPos pt)
|
|
. translate3 (_ebPos pt)
|
|
$ circleSolidCol blue (withAlpha 0.5 white) 8
|
|
|
|
drawFlamelet :: Float -> EnergyBall -> Picture
|
|
drawFlamelet size pt =
|
|
fold
|
|
[ setLayer BloomLayer pic
|
|
, setLayer BloomNoZWrite piu
|
|
, setLayer BloomNoZWrite pi2
|
|
]
|
|
where
|
|
sp = _ebPos pt
|
|
siz2 = size + 0.2
|
|
time = _ebTimer pt
|
|
piu =
|
|
translate3 sp
|
|
-- setDepth (z + 5)
|
|
-- . uncurryV translate sp
|
|
. color
|
|
( mixColors
|
|
(fromIntegral (max 0 (time -2)))
|
|
(10 - fromIntegral time)
|
|
--(V4 2 0 0 1)
|
|
--(V4 2 0 0 1)
|
|
(V4 2 0 0 1)
|
|
(V4 2 0 0 0)
|
|
)
|
|
. rotate (0.1 * fromIntegral time)
|
|
. scale s1 s1
|
|
. polygon
|
|
$ reverse (rectNSWE siz2 (- siz2) (- siz2) siz2)
|
|
pi2 =
|
|
translate3 sp
|
|
--setDepth (z + 5)
|
|
-- . uncurryV translate sp
|
|
. color
|
|
( mixColors
|
|
(fromIntegral (max 0 (time -2)))
|
|
(10 - fromIntegral time)
|
|
--(V4 2 1 0 1)
|
|
--(V4 0 0 0 1)
|
|
(V4 2 1 0 0.5)
|
|
(V4 0 0 0 0)
|
|
)
|
|
. rotate (negate (0.2 * fromIntegral time))
|
|
. scale s2 s2
|
|
. polygon
|
|
. reverse
|
|
$ rectNSWE siz2 (- siz2) (- siz2) siz2
|
|
pic =
|
|
translate3 sp
|
|
--setDepth (z + 2)
|
|
-- . uncurryV translate sp
|
|
. 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))
|
|
. 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)
|