module Dodge.EnergyBall.Draw ( drawEnergyBall, ) where import Dodge.Data.Damage.Type import Dodge.Data.EnergyBall import Geometry import Picture drawEnergyBall :: EnergyBall -> Picture drawEnergyBall eb = case _ebEff eb of (ELECTRICAL, _) -> drawStaticBall eb (FLAMING, _) -> drawFlamelet eb _ -> error "don't know how to draw an energy ball of this type" drawStaticBall :: EnergyBall -> Picture drawStaticBall pt = setLayer BloomNoZWrite . setDepth 20 -- . setDepth (_ebZ pt + 20) . uncurryV translate (_ebPos pt) $ circleSolidCol (_ebColor pt) (withAlpha 0.5 white) (_ebWidth pt + 5) drawFlamelet :: EnergyBall -> Picture drawFlamelet pt = fold [ setLayer BloomLayer pic , setLayer BloomNoZWrite piu , setLayer BloomNoZWrite pi2 ] where z = 20 -- z = _ebZ pt sp = _ebPos pt vel = _ebVel pt ep = sp +.+ vel size = _ebWidth pt siz2 = size + 0.2 time = _ebTimer 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 1) (V4 2 0 0 1) (V4 2 0 0 0) ) . rotate (negate (rot - 0.1 * fromIntegral time)) . scale s1 s1 . polygon $ reverse (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 1) --(V4 0 0 0 1) (V4 2 1 0 0.5) (V4 0 0 0 0) ) . rotate (negate (rot + 0.2 * fromIntegral time)) . scale s2 s2 . polygon . reverse $ 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) rot = _ebRot pt