Get out external function for grid room positions
This commit is contained in:
@@ -46,8 +46,9 @@ roomRect x y xn yn =
|
||||
, _rmLinks = lnks
|
||||
, _rmName = "rect"
|
||||
, _rmPath = pth
|
||||
, _rmPos = map makeonpos (grid xs ys)
|
||||
<> map makeoffpos (grid (mids xs) (mids ys))
|
||||
, _rmPos = gridRoomPos xs ys
|
||||
-- , _rmPos = map makeonpos (grid xs ys)
|
||||
-- <> map makeoffpos (grid (mids xs) (mids ys))
|
||||
, _rmPmnts = []
|
||||
, _rmBound = [rectNSWE (y + 5) (-5) (-5) (x + 5)]
|
||||
, _rmFloor =
|
||||
@@ -56,7 +57,6 @@ roomRect x y xn yn =
|
||||
{ _tilePoly = rectNSWE y 0 0 x
|
||||
, _tileZero = V2 0 0
|
||||
, _tileTangentPos = V2 baseFloorTileSize 0
|
||||
--, _tileArrayZ = 5
|
||||
, _tileArrayZ = 16
|
||||
}
|
||||
]
|
||||
@@ -100,9 +100,33 @@ roomRect x y xn yn =
|
||||
, PathFromEdge East (xn - a)
|
||||
, PathFromEdge West a
|
||||
]
|
||||
--posps = grid -- map (over _1 (+.+ V2 20 20)) $ gridPoints'' xd (xn + 1) yd (yn + 1)
|
||||
mids zs = zipWith (\a b -> 0.5 * (a + b)) zs $ tail zs
|
||||
--interposps = map (over _1 (+.+ V2 (20 + xd / 2) (20 + yd / 2))) $ gridPoints'' xd xn yd yn
|
||||
makeoffpos (p, a) = RoomPos
|
||||
p 0 (S.singleton $ RoomPosOffGrid $ makerpedges' a) (NotLink False) mempty
|
||||
makerpedges' (a, b) =
|
||||
S.fromList
|
||||
[ PathFromEdge South b
|
||||
, PathFromEdge North (yn - (b + 1))
|
||||
, PathFromEdge East (xn - (a + 1))
|
||||
, PathFromEdge West a
|
||||
]
|
||||
|
||||
gridRoomPos :: [Float] -> [Float] -> [RoomPos]
|
||||
gridRoomPos xs ys = map makeonpos (grid xs ys) <> map makeoffpos (grid (mids xs) (mids ys))
|
||||
where
|
||||
yn = length ys - 1
|
||||
xn = length xs - 1
|
||||
grid as bs = [(V2 x' y', (xi,yi)) | (x',xi) <- zip as [0..], (y',yi) <- zip bs [0..]]
|
||||
makeonpos (p, a) = RoomPos p 0 (S.singleton $ RoomPosOnGrid $ makerpedges a)
|
||||
(NotLink True) mempty
|
||||
makerpedges (a, b) =
|
||||
S.fromList
|
||||
[ PathFromEdge South b
|
||||
, PathFromEdge North (yn - b)
|
||||
, PathFromEdge East (xn - a)
|
||||
, PathFromEdge West a
|
||||
]
|
||||
mids zs = zipWith (\a b -> 0.5 * (a + b)) zs $ tail zs
|
||||
makeoffpos (p, a) = RoomPos
|
||||
p 0 (S.singleton $ RoomPosOffGrid $ makerpedges' a) (NotLink False) mempty
|
||||
makerpedges' (a, b) =
|
||||
|
||||
-10
@@ -1,7 +1,5 @@
|
||||
module Grid (
|
||||
gridInPolygon,
|
||||
gridPoints,
|
||||
gridPoints'',
|
||||
latticeXsYs,
|
||||
) where
|
||||
|
||||
@@ -36,13 +34,5 @@ gridPointsOff xoff yoff x nx y ny = map f $ gridPoints' nx ny
|
||||
where
|
||||
f (a, b) = V2 (xoff + fromIntegral a * x) (yoff + fromIntegral b * y)
|
||||
|
||||
gridPoints :: Float -> Int -> Float -> Int -> [Point2]
|
||||
gridPoints = gridPointsOff 0 0
|
||||
|
||||
gridPoints'' :: Float -> Int -> Float -> Int -> [(Point2, (Int, Int))]
|
||||
gridPoints'' x nx y ny = map f $ gridPoints' nx ny
|
||||
where
|
||||
f (a, b) = (V2 (fromIntegral a * x) (fromIntegral b * y), (a, b))
|
||||
|
||||
gridPoints' :: Int -> Int -> [(Int, Int)]
|
||||
gridPoints' nx ny = [(x, y) | x <- [0 .. nx -1], y <- [0 .. ny -1]]
|
||||
|
||||
Reference in New Issue
Block a user