Add file
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
module Dodge.Room.Ngon where
|
||||
import Data.Tile
|
||||
import Dodge.PlacementSpot
|
||||
import Dodge.RoomLink
|
||||
import Dodge.Default.Room
|
||||
import Dodge.LevelGen.Data
|
||||
import Dodge.Placement.Instance
|
||||
--import Dodge.LevelGen.Data
|
||||
import Geometry
|
||||
import Tile
|
||||
|
||||
--import qualified Data.Set as S
|
||||
--import Control.Monad.Loops
|
||||
import Data.Maybe
|
||||
import Data.List
|
||||
|
||||
roomNgon :: Int -> Float -> Room
|
||||
roomNgon n x = defaultRoom
|
||||
{ _rmPolys = [poly]
|
||||
, _rmLinks = map toBothLnk lnks -- muout (init lnks) ++ muin[last lnks]
|
||||
, _rmPath = [] -- TODO
|
||||
, _rmPmnts = [mntLightLnkCond $ resetPLUse $ rprBool $ const . isInLnk]
|
||||
, _rmBound = [poly]
|
||||
, _rmFloor = Tiled [makeTileFromPoly poly 9]
|
||||
, _rmName = show n ++ "gon"
|
||||
}
|
||||
where
|
||||
rot = 2*pi / fromIntegral n
|
||||
rots = map ((rot *) . fromIntegral) [0..n-1]
|
||||
poly = mapMaybe
|
||||
(\(ra,rb) -> intersectLineLine' (rotateV ra bl) (rotateV ra br) (rotateV rb bl) (rotateV rb br))
|
||||
$ loopPairs rots
|
||||
bl = V2 x x
|
||||
br = V2 (-x) x
|
||||
lnks = sortOn ((\(V2 a b) -> (negate b,a)) . fst) $ map (\r -> (rotateV r (V2 0 x),r)) rots
|
||||
Reference in New Issue
Block a user