Locate bug in wall zoning

This commit is contained in:
2021-09-11 00:47:52 +01:00
parent c695767fb0
commit 7c62ef4d48
5 changed files with 84 additions and 55 deletions
+12 -12
View File
@@ -52,26 +52,26 @@ rectanglePairs wdth a b =
norm = wdth *.* normalizeV ( vNormal (b -.- a))
mkSingleDoor :: Color -> Bool -> (World -> Bool) -> Point2 -> Point2 -> Float -> [Int] -> [Wall]
mkSingleDoor c isPathable cond hingep hw speed is
= addSoundToDoor (head is) pld hwd
mkSingleDoor c isPathable cond hingep edgep speed is
= addSoundToDoor (head is) (fst $ head theDoor) (fst $ head shiftedDoor)
$ zipWith3 (linearPane c isPathable cond speed)
is
theDoor
(map (bimap shiftLeft shiftLeft) theDoor)
shiftedDoor
where
theDoor = rectanglePairs 9 hingep hw
shiftLeft = (+.+ (hingep -.- hw))
norm = 9 *.* normalizeV ( vNormal (hw -.- hingep))
pld = hingep -.- norm
hwd = hw -.- norm
theDoor = rectanglePairs 9 hingep edgep
shiftedDoor = map (bimap shiftLeft shiftLeft) theDoor
shiftLeft = (+.+ (hingep -.- edgep))
mkDoubleDoor :: Color -> Bool -> (World -> Bool) -> Point2 -> Point2 -> Float -> [Int] -> [Wall]
mkDoubleDoor c isPathable cond pl pr speed is
= addSoundToDoor (head is) pld hwd $ zipWith3 (linearPane c isPathable cond speed)
is
(leftDoor ++ rightDoor)
(map shiftLeft leftDoor ++ map shiftRight rightDoor)
= addSoundToDoor (head is) (fst $ head leftDoor) (fst $ head shiftedDoor)
$ zipWith3 (linearPane c isPathable cond speed)
is
(leftDoor ++ rightDoor)
shiftedDoor
where
shiftedDoor = map shiftLeft leftDoor ++ map shiftRight rightDoor
leftDoor =
[ (pld +.+ perp,hwd)
, (hwd, hwu)
+10 -10
View File
@@ -16,20 +16,20 @@ import qualified Data.IntMap.Strict as IM
import Control.Lens
-- This deserves a clean up
mvP :: Point2 -> Point2 -> Point2
mvP :: Float -> Point2 -> Point2 -> Point2
{-# INLINE mvP #-}
mvP !ep !p = mvPointTowardAtSpeed 2 ep p
mvP !speed !ep !p = mvPointTowardAtSpeed speed ep p
mvPs :: (Point2,Point2) -> (Point2,Point2) -> (Point2,Point2)
mvPs :: Float -> (Point2,Point2) -> (Point2,Point2) -> (Point2,Point2)
{-# INLINE mvPs #-}
mvPs (!ex,!ey) (!sx,!sy) = (mvP ex sx,mvP ey sy)
mvPs !speed (!ex,!ey) (!sx,!sy) = (mvP speed ex sx,mvP speed ey sy)
moveDoorToward :: Float -> (Point2,Point2) -> Wall -> Wall
{-# INLINE moveDoorToward #-}
--moveDoorToward speed (ex,ey) wls = wls & wlLine %~ mvPs (ex,ey)
moveDoorToward speed (ex,ey) wls = wls & wlLine %~ bimap (f ex) (f ey)
where
f !p = mvPointTowardAtSpeed speed p
moveDoorToward speed (ex,ey) wls = wls & wlLine %~ mvPs speed (ex,ey)
--moveDoorToward !speed !(!ex,!ey) wls = wls & wlLine %~ bimap (f ex) (f ey)
-- where
-- f !p = mvPointTowardAtSpeed speed p
zoneps :: (Point2, Point2) -> [(Int,Int)]
{-# INLINE zoneps #-}
@@ -61,7 +61,7 @@ changeZonedWall
changeZonedWall eff n (x,y) = over wallsZone $ adjustIMZone eff x y n
addSoundToDoor :: Int -> Point2 -> Point2 -> [Wall] -> [Wall]
addSoundToDoor _ _ _ [] = error "When creating door tried to add sound to nothing"
addSoundToDoor _ _ _ [] = error "When creating door tried to add sound to nothing"
addSoundToDoor i pld hwd (x:ys) = f x : ys
where
f wl = over doorMech g wl
@@ -71,4 +71,4 @@ addSoundToDoor i pld hwd (x:ys) = f x : ys
= soundFrom (WallSound i) wp doorSound (Just 1) $ dm w
| otherwise = dm w
where
wp = snd $ _wlLine (_walls w IM.! i)
wp = fst $ _wlLine (_walls w IM.! i)