Fix tile drawing bug

This commit is contained in:
2021-10-04 17:20:18 +01:00
parent a6a3841d36
commit cab8c25610
5 changed files with 25 additions and 9 deletions
+3 -1
View File
@@ -5,6 +5,8 @@ import Tile
import Geometry
import Control.Lens
import Data.List
import Data.Function
addTile :: Float -> Room -> Room
addTile z r
@@ -12,4 +14,4 @@ addTile z r
| otherwise = r & rmFloor .~ [makeTileFromPoly poly z]
where
rp = _rmPolys r
poly = orderPolygon . convexHull $ concat rp
poly = orderPolygon . convexHullSafe . nubBy ((==) `on` roundPoint2) $ concat rp
+8 -2
View File
@@ -75,14 +75,20 @@ combineRooms :: Room -> Room -> Room
combineRooms r r' = defaultRoom
{ _rmPolys = _rmPolys r ++ _rmPolys r'
, _rmLinks = _rmLinks r ++ _rmLinks r'
, _rmPath = (_rmPath r )
++ (_rmPath r')
, _rmPath = map clampPath $ _rmPath r
++ _rmPath r'
, _rmPS = map (shiftPlacement $ _rmShift r) (_rmPS r)
++ map (shiftPlacement $ _rmShift r') (_rmPS r')
, _rmBound = _rmBound r ++ _rmBound r'
, _rmFloor = _rmFloor r ++ _rmFloor r'
, _rmShift = (V2 0 0 , 0)
}
-- not that this assumes that any link paths are integral
clampPath :: (Point2,Point2) -> (Point2, Point2)
clampPath = bimap f f
where
f (V2 x y) = V2 (g x) (g y)
g = (fromIntegral :: Int -> Float) . floor
{- Randomly generate a top fourth of a room possibly with a wall.
Add a light and a 'PutNothing' placement. -}
quarterRoomFlat :: RandomGen g => Float -> State g Room