Implement auto rotate camera when close to walls
This commit is contained in:
@@ -60,6 +60,7 @@ functionalUpdate w = case _menuLayers w of
|
||||
. ppEvents
|
||||
. updateCamera
|
||||
. colCrsWalls
|
||||
. rotateToOverlappingWall
|
||||
. simpleCrSprings
|
||||
. zoneCreatures
|
||||
. updateWalls
|
||||
@@ -250,6 +251,24 @@ crCrSpring c1 c2 w
|
||||
overlap1 = ((comRad - diff) * _crMass c2 * 0.5 / massT) *.* errorNormalizeV 55 vec
|
||||
overlap2 = ((comRad - diff) * _crMass c1 * 0.5 / massT) *.* errorNormalizeV 56 vec
|
||||
massT = _crMass c1 + _crMass c2
|
||||
|
||||
rotateToOverlappingWall :: World -> World
|
||||
rotateToOverlappingWall w = case theWall of
|
||||
Nothing -> w
|
||||
Just wl -> rotateUsing ( (argV . uncurry (-.-) $ _wlLine wl) - camrot)
|
||||
where
|
||||
camrot = _cameraRot w
|
||||
rotateUsing a
|
||||
| b - b' > 0.01 = w & cameraRot +~ 0.01
|
||||
| b - b' < negate 0.01 = w & cameraRot -~ 0.01
|
||||
| otherwise = w
|
||||
where
|
||||
b = a * (2 / pi)
|
||||
b' = fromIntegral $ (round b :: Int)
|
||||
cr = you w
|
||||
p = _crPos cr
|
||||
theWall = collideCircWallsReturnWall p (_crRad cr + 5) (wallsNearPoint p w)
|
||||
|
||||
{-
|
||||
Finds the IDs of visible walls from a point to another point. -}
|
||||
visibleWalls :: Point2 -> Point2 -> IM.IntMap Wall -> [Int]
|
||||
|
||||
Reference in New Issue
Block a user