module Dodge.Projectile.Draw ( drawProjectile ) where import Data.Strict.Tuple import Dodge.Data.Item.Use.Consumption.Ammo import Dodge.Data.Projectile import Geometry import Picture import Shape import ShapePicture import Control.Lens drawProjectile :: Projectile -> SPic drawProjectile pj | Just (DestroyPU {}) <- pj ^? prjUpdates . ix 0 = mempty | Just NoHoming <- pj ^? prjType . rocketHoming = drawShell Nothing pj | Just _ <- pj ^? prjType . rocketHoming = drawRemoteShell pj | otherwise = drawShell Nothing pj drawShell :: Maybe Color -> Projectile -> SPic drawShell mcol pj = noPic . translateSHz (_prjZ pj) . uncurryV translateSHxy (_prjPos pj) $ rotateSH (_prjDir pj) shellShape shellShape :: Shape shellShape = colorSH black $ upperPrismPoly Small Typical 4 $ map toV2 [(-6, 4), (-6, -4), (6, -4), (8, 0), (6, 4)] drawRemoteShell :: Projectile -> SPic drawRemoteShell pj | rem (t + 200) 20 < 9 = doposition $ noPic shellShape | otherwise = doposition $ remoteShellShape col where col | t > (-99) = green | otherwise = red t = _prjTimer pj doposition = translateSPz 18 . uncurryV translateSPxy (_prjPos pj) . rotateSP (_prjDir pj) remoteShellShape :: Color -> SPic remoteShellShape col = shellShape :!: ( setLayer BloomNoZWrite . setDepth 4.5 . color col $ circleSolid 3)