Fix long door bug.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user