Cleanup. Add room-wise random placement spots

This commit is contained in:
2021-11-07 19:46:14 +00:00
parent f380e140e1
commit 5681a37953
18 changed files with 179 additions and 141 deletions
+20 -1
View File
@@ -1,10 +1,16 @@
{-# LANGUAGE BangPatterns #-}
module Dodge.Wall.Move
where
( moveWallID
, moveWall
, moveWallIDToward
) where
import Dodge.Data
import Dodge.Base
import Geometry
import Dodge.Wall.Zone
import Control.Lens
import qualified Data.IntMap.Strict as IM
moveWallID :: Int -> (Point2,Point2) -> World -> World
moveWallID wlid wlline w = case w ^? walls . ix wlid of
Nothing -> w
@@ -15,3 +21,16 @@ moveWall wlid wl wlline w = w & walls . ix wlid .~ newwl
& insertWallInZones newwl
where
newwl = wl {_wlLine = wlline}
moveWallIDToward :: Int -> Float -> (Point2,Point2) -> World -> World
moveWallIDToward wlid speed ep w = moveWall wlid wl newwlline w
where
wl = _walls w IM.! wlid
newwlline = mvPs speed ep (_wlLine wl)
mvP :: Float -> Point2 -> Point2 -> Point2
{-# INLINE mvP #-}
mvP !speed !ep !p = mvPointTowardAtSpeed speed ep p
mvPs :: Float -> (Point2,Point2) -> (Point2,Point2) -> (Point2,Point2)
{-# INLINE mvPs #-}
mvPs !speed (!ex,!ey) (!sx,!sy) = (mvP speed ex sx,mvP speed ey sy)