Add concept of GameRoom, check viewing distance based on rooms

This commit is contained in:
2021-09-02 23:24:29 +01:00
parent 9d2f42dbc9
commit c69af7a5f4
30 changed files with 295 additions and 151 deletions
+6 -1
View File
@@ -128,15 +128,20 @@ addPointPolygon p ps
| pointInOrOnPolygon p ps = ps
| otherwise = orderPolygon $ p : ps
-- | Creates the convex hull of a set of points.
-- Need to verify whether or not this is ordered
convexHull :: [Point2] -> [Point2]
convexHull (x:y:z:xs) = grahamScan $ orderAroundFirst $ sortOn (\(V2 a b) -> (b,a)) (x:y:z:xs)
convexHull _ = error "Tried to create the convex hull of two or fewer points"
-- | Creates the convex hull of a set of points.
-- Need to verify whether or not this is ordered
convexHullSafe :: [Point2] -> [Point2]
convexHullSafe (x:y:z:xs) = grahamScan $ orderAroundFirst $ sortOn (\(V2 a b) -> (b,a)) (x:y:z:xs)
convexHullSafe _ = []
grahamScan :: [Point2] -> [Point2]
grahamScan = foldr push []
where
push point stack = grahamEliminate (point:stack)
-- | Remove second element if top three elements are not counterclockwise.
-- Repeat if necessary. See
-- https://codereview.stackexchange.com/questions/206019/graham-scan-algorithm-in-haskell