Refactor projectiles

This commit is contained in:
2022-07-20 09:55:07 +01:00
parent 9daf872878
commit 330a81a955
14 changed files with 196 additions and 200 deletions
+12 -11
View File
@@ -5,19 +5,20 @@ import Picture
import Shape
import ShapePicture
drawProjectile :: ProjectileDraw -> Prop -> SPic
drawProjectile pd = case pd of
DrawShell -> drawShell
DrawRemoteShell -> drawRemoteShell
drawShell :: Prop -> SPic
drawProjectile :: Proj -> SPic
drawProjectile prj = case _prjDraw prj of
DrawShell -> drawShell prj
DrawRemoteShell -> drawRemoteShell prj
DrawDrone -> drawShell prj
DrawBlankProjectile -> mempty
drawShell :: Proj -> SPic
drawShell pj = noPic
. translateSHz 18
. uncurryV translateSHf (_prPos pj)
$ rotateSH (argV $ _pjAcc pj) shellShape
. uncurryV translateSHf (_prjPos pj)
$ rotateSH (argV $ _prjAcc pj) shellShape
shellShape :: Shape
shellShape = colorSH black $ upperPrismPoly 4 $ map toV2 [(-6,4),(-6,-4),(6,-4),(8,0),(6,4)]
drawRemoteShell :: Prop -> SPic
drawRemoteShell :: Proj -> SPic
drawRemoteShell pj
| rem (t+200) 20 < 9
= doposition $ noPic shellShape
@@ -25,8 +26,8 @@ drawRemoteShell pj
where
col | t > (-99) = green
| otherwise = red
t = _pjTimer pj
doposition = translateSPz 18 . uncurryV translateSPf (_prPos pj) . rotateSP (_pjDir pj)
t = _prjTimer pj
doposition = translateSPz 18 . uncurryV translateSPf (_prjPos pj) . rotateSP (_prjDir pj)
remoteShellShape :: Color -> SPic
remoteShellShape col = (shellShape
, setLayer BloomNoZWrite . setDepth 4.5 . color col $ circleSolid 3