Fix space leak, start to unify door mechanisms

This commit is contained in:
jgk
2021-07-20 13:42:38 +02:00
parent 40ee81aff9
commit 316a4141ab
3 changed files with 7 additions and 13 deletions
+1 -1
View File
@@ -460,7 +460,7 @@ mvPointTowardAtSpeed
-> Point2 -- ^ End point.
-> Point2 -- ^ Start point.
-> Point2
mvPointTowardAtSpeed speed !ep !p
mvPointTowardAtSpeed !speed !ep !p
| dist p ep < speed = ep
| otherwise = p +.+ speed *.* normalizeV (ep -.- p)
{- | given a target and a start point, shift toward the end point by 1.
+3 -6
View File
@@ -10,6 +10,7 @@ import Dodge.Base
import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms
import Dodge.Creature.Property
import Dodge.LevelGen.MoveDoor
import Geometry
import Picture
import qualified DoubleStack as DS
@@ -103,12 +104,8 @@ autoDoorPane (trigx,trigy) n closedPos openPos = Door
= flip (foldr changeZonedWall) zoneps $ over walls (IM.adjust openDoor n) w
| otherwise
= flip (foldr changeZonedWall') zoneps $ over walls (IM.adjust closeDoor n) w
mvP !ep !p = mvPointTowardAtSpeed 2 ep p
mvPs (ex,ey) (sx,sy) = (mvP ex sx,mvP ey sy)
moveToward :: (Point2,Point2) -> Wall -> Wall
moveToward (ex,ey) wls = wls & wlLine %~ mvPs (ex,ey)
openDoor = moveToward openPos
closeDoor = moveToward closedPos
openDoor = moveDoorToward openPos
closeDoor = moveDoorToward closedPos
zoneps | dist a b <= 2 * zoneSize = [zoneOfPoint $ pHalf a b]
| otherwise = map zoneOfPoint $ divideLine (2*zoneSize) a b
changeZonedWall (!x,!y) = over wallsZone $ adjustIMZone openDoor x y n
+3 -6
View File
@@ -7,6 +7,7 @@ import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms
import Dodge.LevelGen.Switch
import Dodge.LevelGen.Pathing
import Dodge.LevelGen.MoveDoor
import Picture
import Geometry
import qualified DoubleStack as DS
@@ -162,12 +163,8 @@ triggerDoorPaneLinear c cond n closedPos openPos = Door
$ over walls (IM.adjust closeDoor n) w -- . wlLine . ix 0) (mvPointToward a)
zoneps | dist a b <= 2 * zoneSize = [zoneOfPoint $ pHalf a b]
| otherwise = map zoneOfPoint $ divideLine (2*zoneSize) a b
mvP !ep !p = mvPointTowardAtSpeed 2 ep p
mvPs (ex,ey) (sx,sy) = (mvP ex sx,mvP ey sy)
moveToward :: (Point2,Point2) -> Wall -> Wall
moveToward (ex,ey) wls = wls & wlLine %~ mvPs (ex,ey)
openDoor = moveToward openPos
closeDoor = moveToward closedPos
openDoor = moveDoorToward openPos
closeDoor = moveDoorToward closedPos
changeZonedWall (!x,!y)
= over wallsZone $ adjustIMZone openDoor x y n
changeZonedWall' (!x,!y)