Add no weapon start
This commit is contained in:
@@ -35,26 +35,26 @@ nearCollinear (a,b) (x,y)
|
||||
-- | Remove inverse walls.
|
||||
removeInverseWalls :: [WallP] -> [WallP]
|
||||
removeInverseWalls ((a,b):ps)
|
||||
| elem (b,a) ps = removeInverseWalls $ delete (b,a) ps
|
||||
| otherwise = (a,b) : (removeInverseWalls ps)
|
||||
| (b,a) `elem` ps = removeInverseWalls $ delete (b,a) ps
|
||||
| otherwise = (a,b) : removeInverseWalls ps
|
||||
removeInverseWalls ps = ps
|
||||
|
||||
-- | Cut out a polygon from a set of walls, and check for errors in the
|
||||
-- created walls.
|
||||
-- If created walls are not consistent, expand poly and retry.
|
||||
cutWalls :: [Point2] -> [WallP] -> [WallP]
|
||||
cutWalls ps wls = case mapMaybe (flip checkWallRight newWalls) newWalls of
|
||||
cutWalls ps wls = case mapMaybe (`checkWallRight` newWalls) newWalls of
|
||||
[] -> newWalls
|
||||
_ -> cutWalls (expandPolyBy 0.01 ps) wls
|
||||
where
|
||||
newWalls = cutWalls' ps wls
|
||||
errsL = mapMaybe (flip checkWallLeft newWalls) newWalls
|
||||
errsL = mapMaybe (`checkWallLeft` newWalls) newWalls
|
||||
|
||||
-- | Cut out a polygon from a set of walls, and check for errors in the
|
||||
-- created walls.
|
||||
-- Give error if created walls are not consistent.
|
||||
cutWalls'' :: [Point2] -> [WallP] -> [WallP]
|
||||
cutWalls'' ps wls = case mapMaybe (flip checkWallRight newWalls) newWalls of
|
||||
cutWalls'' ps wls = case mapMaybe (`checkWallRight` newWalls) newWalls of
|
||||
[] -> newWalls
|
||||
errs -> error $ "during level generation function cutWalls: when cutting poly:\n" ++ show ps
|
||||
++ "\nRight corner errors:\n"
|
||||
@@ -67,7 +67,7 @@ cutWalls'' ps wls = case mapMaybe (flip checkWallRight newWalls) newWalls of
|
||||
++ unlines (map show newWalls)
|
||||
where
|
||||
newWalls = cutWalls' ps wls
|
||||
errsL = mapMaybe (flip checkWallLeft newWalls) newWalls
|
||||
errsL = mapMaybe (`checkWallLeft` newWalls) newWalls
|
||||
|
||||
-- | Given a specific wall and list of walls, checks that the number of walls leaving the
|
||||
-- second point is the same as the number of walls entering the second point of
|
||||
@@ -126,7 +126,7 @@ cutWalls' qs walls =
|
||||
expandPolyBy :: Float -> [Point2] -> [Point2]
|
||||
expandPolyBy x ps = map f ps
|
||||
where
|
||||
cp = (1/(fromIntegral (length ps))) *.* (foldr (+.+) (0,0) ps)
|
||||
cp = 1/(fromIntegral (length ps)) *.* foldr (+.+) (0,0) ps
|
||||
f p = p +.+ x *.* (p -.- cp)
|
||||
|
||||
-- | Given a polygon expressed as a list of points and a collection of walls,
|
||||
@@ -144,7 +144,7 @@ cutWallsWithPoints (p:ps) ws = foldr f ([],ws) (zip (p:ps) (ps++[p]))
|
||||
-- | List the points of intersection between a segment and collection of walls.
|
||||
cutWallsPoints :: Point2 -> Point2 -> [WallP] -> [Point2]
|
||||
--cutWallsPoints p1 p2 ws = mapMaybe (\(x:y:_) -> intersectExtendedSegSeg p1 p2 x y)
|
||||
cutWallsPoints p1 p2 ws = mapMaybe (uncurry $ myIntersectSegSeg p1 p2) ws
|
||||
cutWallsPoints p1 p2 = mapMaybe (uncurry $ myIntersectSegSeg p1 p2)
|
||||
|
||||
-- | Given a segment and a wall, split the wall into two if it crosses the segment.
|
||||
cutWall :: Point2 -> Point2 -> WallP -> [WallP]
|
||||
@@ -171,9 +171,7 @@ addPolyWall (p1,p2) walls =
|
||||
where
|
||||
p3 = 0.5 *.* (p1 +.+ p2)
|
||||
p4 = p3 +.+ 10000 *.* vNormal (p2 -.- p1)
|
||||
maybeWs = -- listToMaybe .
|
||||
fmap (fst . unzip)
|
||||
-- . fmap unzip
|
||||
maybeWs = fmap (map fst)
|
||||
. listToMaybe
|
||||
$ groupBy ((==) `on` (dist p3 . snd))
|
||||
wlsP
|
||||
@@ -224,10 +222,6 @@ wallIsZeroLength (x,y) = x == y
|
||||
|
||||
-- | Given a polygon and list of walls, removes walls inside the polygon.
|
||||
removeWallsInPolygon :: [Point2] -> [WallP] -> [WallP]
|
||||
removeWallsInPolygon ps walls = filter (not . cond) walls
|
||||
removeWallsInPolygon ps = filter (not . cond)
|
||||
where
|
||||
cond wall =
|
||||
pointInOrOnPolygon (0.5 *.* (fst wall +.+ snd wall)) ps
|
||||
-- pointInOrOnPolygon (fst wall) ps
|
||||
-- && pointInOrOnPolygon (snd wall) ps
|
||||
|
||||
cond wall = pointInOrOnPolygon (0.5 *.* uncurry (+.+) wall) ps
|
||||
|
||||
Reference in New Issue
Block a user