Fix terminal shape

This commit is contained in:
2026-04-10 11:19:16 +01:00
parent b197e22de7
commit f19e165571
8 changed files with 36 additions and 31 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ crabFeet _ cr =
f p q = q + 2 *^ (p - q) f p q = q + 2 *^ (p - q)
cdir = -cr ^. crDir cdir = -cr ^. crDir
cxy = cr ^. crPos . _xy cxy = cr ^. crPos . _xy
afoot = upperPrismPolyST 10 $ polyCirc 3 2 afoot = upperPrismPolyHalfST 10 $ polyCirc 3 2
(r1,r2) = spiderJoint (0 & _xy .~ rpos) (V3 0 2 5) (r1,r2) = spiderJoint (0 & _xy .~ rpos) (V3 0 2 5)
rpos' = f (V2 0 10) rpos rpos' = f (V2 0 10) rpos
(r1',r2') = spiderJoint (0 & _xy .~ rpos') (V3 0 2 5) (r1',r2') = spiderJoint (0 & _xy .~ rpos') (V3 0 2 5)
+3 -3
View File
@@ -33,16 +33,16 @@ updateCarriage' cid cr w = \case
& tocr . crStance . carriage . zSpeed & tocr . crStance . carriage . zSpeed
%~ if cr ^. crPos . _z < 17 then min 0.05 . (+0.001) else max (-0.05) . subtract 0.001 %~ if cr ^. crPos . _z < 17 then min 0.05 . (+0.001) else max (-0.05) . subtract 0.001
Boosting {} -> w Boosting {} -> w
Falling {_fallRot = q} -> Falling {_fallRot = q, _carDir = q'} ->
let v = 0.95 *^ (cr ^. crOldPos - oop & _z -~ 0.5) let v = 0.95 *^ (cr ^. crOldPos - oop & _z -~ 0.5)
ep = cr ^. crPos + v ep = cr ^. crPos + v
in if ep ^. _z < 0 && cr ^. crOldPos . _z >= 0 && in if ep ^. _z < 0 && cr ^. crOldPos . _z >= 0 &&
(not (any (pointInPoly (ep ^. _xy)) (w ^. cWorld . chasms)) (not (any (pointInPoly (ep ^. _xy)) (w ^. cWorld . chasms))
|| any (uncurry $ crOnSeg cr) (w ^. cWorld . cliffs)) || any (uncurry $ crOnSeg cr) (w ^. cWorld . cliffs))
then w & tocr . crPos .~ (ep & _z .~ 0) then w & tocr . crPos .~ (ep & _z .~ 0)
& cWorld . lWorld . creatures . ix cid . crStance . carriage .~ OnGround & cWorld . lWorld . creatures . ix cid . crStance . carriage .~ OnGround q'
else w & cWorld . lWorld . creatures . ix cid . crPos .~ ep else w & cWorld . lWorld . creatures . ix cid . crPos .~ ep
& cWorld . lWorld . creatures . ix cid . crStance . carriage . fallDir *~ q & cWorld . lWorld . creatures . ix cid . crStance . carriage . carDir *~ q
OnGround {} -> w OnGround {} -> w
& tocr . crPos . _xy +~ 0.8 *^ (cr ^. crOldPos . _xy - oop ^. _xy) & tocr . crPos . _xy +~ 0.8 *^ (cr ^. crOldPos . _xy - oop ^. _xy)
+3 -4
View File
@@ -55,9 +55,8 @@ updateLivingCreature cr =
ChaseCrit{} -> \w -> ChaseCrit{} -> \w ->
crUpdate cid . performActions cid $ crUpdate cid . performActions cid $
over (cWorld . lWorld . creatures . ix cid) (chaseCritInternal w) w over (cWorld . lWorld . creatures . ix cid) (chaseCritInternal w) w
CrabCrit{} -> \w -> CrabCrit{} ->
crUpdate cid . performActions cid $ crUpdate cid . performActions cid . crabCritInternal cid
crabCritInternal cid w
AutoCrit {} -> crUpdate cid AutoCrit {} -> crUpdate cid
SwarmCrit {} -> crUpdate cid SwarmCrit {} -> crUpdate cid
HoverCrit {} -> \w -> HoverCrit {} -> \w ->
@@ -129,7 +128,7 @@ startDeathTimer cr = cr
toDeathCarriage :: Carriage -> Carriage toDeathCarriage :: Carriage -> Carriage
toDeathCarriage = \case toDeathCarriage = \case
Flying {} -> Falling Q.qid Q.qid Flying {} -> Falling Q.qid Q.qid
Walking -> OnGround Walking -> OnGround Q.qid
_ -> Falling Q.qid Q.qid _ -> Falling Q.qid Q.qid
-- could look at the amount of damage here (given by maxDamage) too -- could look at the amount of damage here (given by maxDamage) too
+2 -2
View File
@@ -25,8 +25,8 @@ data Carriage
| Floating | Floating
| Flying {_zSpeed :: Float, _flyInertia :: Float} | Flying {_zSpeed :: Float, _flyInertia :: Float}
| Boosting Point2 | Boosting Point2
| Falling {_fallRot :: Quaternion Float, _fallDir :: Quaternion Float} | Falling {_fallRot :: Quaternion Float, _carDir :: Quaternion Float}
| OnGround | OnGround {_carDir :: Quaternion Float}
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data FootForward = LeftForward | RightForward data FootForward = LeftForward | RightForward
+4 -2
View File
@@ -1,5 +1,6 @@
module Dodge.Machine.Draw (drawMachine,mcColor) where module Dodge.Machine.Draw (drawMachine,mcColor) where
import Linear
import Control.Lens import Control.Lens
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Maybe import Data.Maybe
@@ -56,11 +57,12 @@ terminalShape lw mc = fromMaybe mempty $ do
( prismBox ( prismBox
Medium Medium
Typical Typical
[V3 10 10 20, V3 (-10) 10 20, V3 (-10) (-10) 10, V3 10 (-10) 10] tps
(addZ 0 `map` rectWH 10 10) (tps & each . _z .~ 0)
) )
<> screenbackground (getcol term) <> screenbackground (getcol term)
where where
tps = [V3 10 10 20, V3 (-10) 10 20, V3 (-10) (-10) 10, V3 10 (-10) 10]
getcol term = fromMaybe black $ termScreenColor term getcol term = fromMaybe black $ termScreenColor term
screenbackground col = screenbackground col =
colorSH colorSH
+2 -2
View File
@@ -123,8 +123,8 @@ drawCreature w m cr = translateSP (_crPos cr) . fallrot . rotateSP (_crDir cr) $
CrabCrit {} -> noPic $ drawCrabCrit w cr CrabCrit {} -> noPic $ drawCrabCrit w cr
HoverCrit{} -> noPic $ drawHoverCrit cr HoverCrit{} -> noPic $ drawHoverCrit cr
where where
fallrot = case cr ^. crStance . carriage of fallrot = case cr ^? crStance . carriage . carDir of
Falling {_fallDir = q} -> _1 . each . sfVs . each %~ Q.rotate q Just q -> _1 . each . sfVs . each %~ Q.rotate q
_ -> id _ -> id
barrelShape :: SPic barrelShape :: SPic
+3 -4
View File
@@ -339,14 +339,13 @@ chasmSpitTerminal = do
, [sps0 $ putShape $ gird (V2 0 20) (V2 300 20), sps0 $ putShape $ gird (V2 0 280) (V2 300 280)] , [sps0 $ putShape $ gird (V2 0 20) (V2 300 20), sps0 $ putShape $ gird (V2 0 280) (V2 300 280)]
] ]
let y' = y & rmPmnts <>~ ls <> dec let y' = y & rmPmnts <>~ ls <> dec
cr = PutCrit chaseCrit
return $ return $
tToBTree "chasmTerm" $ tToBTree "chasmTerm" $
Node Node
(addDoorToggleTerminal' i1 (PS 150 0) y') (addDoorToggleTerminal' i1 (PS 150 0) y')
[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit crabCrit)] [ treePost [triggerDoorRoom i1, deadEndPSType cr]
--[ treePost [triggerDoorRoom i1, deadEndPSType (PutCrit hoverCrit)] , treePost [triggerDoorRoom i1, deadEndPSType cr]
--[ treePost [triggerDoorRoom i1, deadEndRoom]
, treePost [triggerDoorRoom i1, deadEndPSType (PutCrit crabCrit)]
, return $ cleatOnward $ triggerDoorRoom i1 , return $ cleatOnward $ triggerDoorRoom i1
] ]
where where
+18 -13
View File
@@ -17,6 +17,7 @@ module Shape (
upperPrismPolyHalf, upperPrismPolyHalf,
upperPrismPolyHalfMI, upperPrismPolyHalfMI,
upperPrismPolyHalfST, upperPrismPolyHalfST,
upperPrismPolyScale,
xCylinderST, xCylinderST,
prismPoly, prismPoly,
prismBox, prismBox,
@@ -57,12 +58,7 @@ polyCircx n = map (vNormaly . addZ 0) . polyCirc n
-- points should be correctly ordered so that -- points should be correctly ordered so that
-- polys form a prism-like object with quad faces between them -- polys form a prism-like object with quad faces between them
-- each layer of points must be arranged anticlockwise -- each layer of points must be arranged anticlockwise
prismPoly :: prismPoly :: Size -> Importance -> [Point3] -> [Point3] -> Shape
Size ->
Importance ->
[Point3] ->
[Point3] ->
Shape
{-# INLINE prismPoly #-} {-# INLINE prismPoly #-}
prismPoly size shads upps downps = [Surface (RoundedFaces n) (cp : cp : f upps downps) white shads size] prismPoly size shads upps downps = [Surface (RoundedFaces n) (cp : cp : f upps downps) white shads size]
where where
@@ -201,13 +197,7 @@ upperPrismPolyHalfMI = upperPrismPolyHalf Medium Important
upperPrismPolyHalfST :: Float -> [Point2] -> Shape upperPrismPolyHalfST :: Float -> [Point2] -> Shape
upperPrismPolyHalfST = upperPrismPolyHalf Small Typical upperPrismPolyHalfST = upperPrismPolyHalf Small Typical
upperPrismPolyHalf :: upperPrismPolyHalf :: Size -> Importance -> Float -> [Point2] -> Shape
-- | height, expected to be strictly positive
Size ->
Importance ->
Float ->
[Point2] ->
Shape
{-# INLINE upperPrismPolyHalf #-} {-# INLINE upperPrismPolyHalf #-}
upperPrismPolyHalf size shad h ps = prismPoly size shad upps downps upperPrismPolyHalf size shad h ps = prismPoly size shad upps downps
where where
@@ -216,6 +206,21 @@ upperPrismPolyHalf size shad h ps = prismPoly size shad upps downps
f (V2 x y) = V3 (0.5 * x) (0.5 * y) h f (V2 x y) = V3 (0.5 * x) (0.5 * y) h
g (V2 x y) = V3 x y 0 g (V2 x y) = V3 x y 0
upperPrismPolyScale ::
Float ->
Size ->
Importance ->
Float ->
[Point2] ->
Shape
{-# INLINE upperPrismPolyScale #-}
upperPrismPolyScale s size shad h ps = prismPoly size shad upps downps
where
upps = map f ps
downps = map g ps
f (V2 x y) = V3 (s * x) (s * y) h
g (V2 x y) = V3 x y 0
upperBoxHalf :: upperBoxHalf ::
-- | height, expected to be strictly positive -- | height, expected to be strictly positive
Size -> Size ->