Fix long door bug.

This commit is contained in:
2021-08-17 20:59:10 +02:00
parent 92c897e6a2
commit 4b7562521c
7 changed files with 40 additions and 4 deletions
+10
View File
@@ -2,6 +2,7 @@
module Dodge.LevelGen.TriggerDoor
( putDoor
, putDoubleDoor
, putSingleDoor
, addButtonDoor
, addSwitchDoor
) where
@@ -81,16 +82,25 @@ putDoubleDoor c cond a b = over walls triggerDoubleDoor
where
is = [IM.newKey wls..]
putSingleDoor :: Color -> (World -> Bool) -> Point2 -> Point2 -> World -> World
putSingleDoor c cond a b = over walls putTheDoor
where
putTheDoor wls = IM.union wls $ IM.fromList $ zip is $ mkSingleDoor c False cond a b is
where
is = [IM.newKey wls..]
mkTriggerDoor
:: Color
-> (World -> Bool) -- ^ Opening condition
-> [(Point2,Point2)] -- ^ List of wall position pairs, closed to open
-> [Int] -- ^ Wall ids
-> [Wall]
{-# INLINE mkTriggerDoor #-}
mkTriggerDoor c cond ppairs is = zipWith (triggerDoorPane c cond) is $
transpose $ map toPanePoints ppairs
toPanePoints :: (Point2,Point2) -> [(Point2,Point2)]
{-# INLINE toPanePoints #-}
toPanePoints (x,y) =
[ (y +.+ perp, y -.- perp)
, (y -.- perp, x -.- perp)