Smooth out slime splitting

There are probably possible errors from the use of cutPoly
This commit is contained in:
2026-05-08 23:44:28 +01:00
parent 34d8425520
commit 12e4a278d0
10 changed files with 243 additions and 204 deletions
+7 -9
View File
@@ -7,6 +7,7 @@ module Dodge.Creature.Picture (
drawCreature,
) where
import Dodge.Creature.Slime
import Geometry.Zone
import Data.Foldable
import qualified Data.Strict.Tuple as ST
@@ -58,17 +59,14 @@ drawCreature w m cr = translateSP (_crPos cr) . fallrot . rotateSP (_crDir cr) $
drawSlimeCrit :: Creature -> Shape
drawSlimeCrit cr = colorSH green
$ upperPrismPolyHalf Medium Typical (cr ^?! crType . slimeEngulfProgress + min 15 r) $ polyCirc 6 r
& each . _x *~ p
& each . _y %~ (/p)
-- & each %~ scaleAlong d s
-- & each %~ scaleAlong (vNormal d) (1 / s)
-- & each %~ rotateV (-cr ^. crDir)
$ upperPrismPolyHalf Medium Typical (cr ^?! crType . slimeEngulfProgress + min 15 r) ps
where
r = slimeToRad $ cr ^?! crType . slimeSlime - cr ^?! crType . slimeSlimeChange
p = cr ^?! crType . slimeCompression
-- d = normalize p
-- s = norm p / r
so = slimeOutline cr
ps = fromMaybe so $ do
(x',qs) <- cr ^? crType . slimeSplitTimer . _Just
let x = fromIntegral x'
return $ zipWith (+) (fmap (0.1*(10 - x) *^) so) (fmap (0.1*x*^) qs)
-- assumes d is a unit vector
scaleAlong :: Point2 -> Float -> Point2 -> Point2