Add pathing to roomNgon

This commit is contained in:
2025-10-04 00:19:33 +01:00
parent cba3ca784a
commit a642198bfc
3 changed files with 39 additions and 33 deletions
+7 -1
View File
@@ -1,5 +1,7 @@
{-# LANGUAGE TupleSections #-}
module Dodge.Room.Ngon where
import Dodge.Room.Path
import Data.List
import qualified Data.Set as S
--import Data.Maybe
@@ -19,7 +21,7 @@ roomNgon n x = do
defaultRoom
{ _rmPolys = [poly]
, _rmLinks = map f lnks -- muout (init lnks) ++ muin[last lnks]
, _rmPath = mempty -- TODO
, _rmPath = linksGridToPath (map f lnks) path4
, _rmPmnts = [thelight]
, _rmBound = [poly]
, _rmFloor = Tiled [makeTileFromPoly poly 2]
@@ -30,6 +32,10 @@ roomNgon n x = do
rots = map ((rot *) . fromIntegral) [0 .. n -1]
poly = polyOrthDist n x
path1 = polyOrthDist n (x-10)
path2 = concat $ zipWith g path1 (tail path1 <> [head path1])
path3 = loopPairs path2 <> fmap (,V2 0 0) path2
path4 = concatMap doublePair path3
g z y = [z, 0.5 * (z + y)]
lnks =
sortOn ((\(V2 a b) -> (negate b, a)) . fst . snd)
. zip [0 ..]