Refactor projectiles, fix shell drawing

This commit is contained in:
2024-12-27 23:27:53 +00:00
parent 233fe5995c
commit ed5c5d7b8a
7 changed files with 35 additions and 63 deletions
+19 -21
View File
@@ -1,7 +1,8 @@
module Dodge.Projectile.Draw
( drawProjectile
) where
module Dodge.Projectile.Draw (
drawProjectile,
) where
import Control.Lens
import Data.Strict.Tuple
import Dodge.Data.Item.Use.Consumption.Ammo
import Dodge.Data.Projectile
@@ -9,40 +10,37 @@ 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 =
drawProjectile pj
| Just (DestroyPU{}) <- pj ^? prjUpdates . ix 0 = mempty
| Just NoHoming <- pj ^? prjType . rkHoming =
drawShell Nothing pj
| Just _ <- pj ^? prjType . rocketHoming =
| Just _ <- pj ^? prjType . rkHoming =
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
translateSPz (_prjZ pj)
. uncurryV translateSPxy (_prjPos pj)
$ rotateSP (_prjDir pj) $
shellShape :!: thelight
where
thelight =
foldMap
(\col -> setLayer BloomNoZWrite . setDepth 4.5 . color col $ circleSolid 3)
mcol
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
| rem (t + 200) 20 < 9 = drawShell Nothing pj
| otherwise = drawShell (Just col) pj
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)