Add menu option for auto camera rotation
This commit is contained in:
+4
-17
@@ -197,6 +197,7 @@ reflectCircCreatures rad p1 p2 cs
|
||||
$ IM.mapMaybe (reflectCircCreature rad p1 p2) cs
|
||||
where
|
||||
f (a,_,_) = magV (a -.- p1)
|
||||
|
||||
-- | collides a point with forcefields
|
||||
-- if found, returns point of collision, deflection if required, and the id
|
||||
collidePointFFs :: a
|
||||
@@ -204,24 +205,10 @@ collidePointFFs = undefined
|
||||
collidePointFF :: a
|
||||
collidePointFF = undefined
|
||||
--
|
||||
--collidePointFFs :: Point2 -> Point2 -> StdGen -> IM.IntMap ForceField
|
||||
-- -> Maybe (Point2,(Maybe (Point2,StdGen),Int))
|
||||
--collidePointFFs p1 p2 g fs = listToMaybe $ sortBy f $ IM.elems
|
||||
-- $ IM.mapMaybe (collidePointFF p1 p2 g) fs
|
||||
-- where f (a,_) (b,_) = compare (magV (p1 -.- a)) (magV (p1 -.- b))
|
||||
--
|
||||
--collidePointFF :: Point2 -> Point2 -> StdGen -> ForceField
|
||||
-- -> Maybe (Point2,(Maybe (Point2,StdGen),Int))
|
||||
--collidePointFF p1 p2 g ff = fmap f ip
|
||||
-- where (p3:p4:_) = _ffLine ff
|
||||
-- ip = intersectSegSeg p1 p2 p3 p4
|
||||
-- ref = (_ffDeflect ff) <*> Just g <*> Just (p2 -.- p1) <*> Just ff
|
||||
-- f p = (p, (ref, _ffID ff))
|
||||
|
||||
-- | Looks for first collision of a circle with walls.
|
||||
-- | Looks for overlap of a circle with walls.
|
||||
-- If found, gives wall
|
||||
collideCircWallsReturnWall :: Point2 -> Float -> IM.IntMap Wall -> Maybe Wall
|
||||
collideCircWallsReturnWall p rad ws
|
||||
overlapCircWallsReturnWall :: Point2 -> Float -> IM.IntMap Wall -> Maybe Wall
|
||||
overlapCircWallsReturnWall p rad ws
|
||||
= L.fold (safeMinimumOnMaybeL (fmap (dist p) . f . _wlLine))
|
||||
ws
|
||||
where
|
||||
|
||||
@@ -12,6 +12,7 @@ module Dodge.Config.Data (
|
||||
, resolution_factor
|
||||
, windowX
|
||||
, windowY
|
||||
, rotate_to_wall
|
||||
) where
|
||||
|
||||
import Data.Aeson
|
||||
@@ -27,6 +28,7 @@ data Configuration = Configuration
|
||||
, _resolution_factor :: Int -- ^ Higher values divide screen size, i.e. make the resolution worse
|
||||
, _windowX :: Float
|
||||
, _windowY :: Float
|
||||
, _rotate_to_wall :: Bool
|
||||
}
|
||||
deriving (Generic, Show)
|
||||
makeLenses ''Configuration
|
||||
@@ -46,4 +48,5 @@ defaultConfig = Configuration
|
||||
, _resolution_factor = 1
|
||||
, _windowX = 800
|
||||
, _windowY = 600
|
||||
, _rotate_to_wall = True
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module Dodge.Event.Menu
|
||||
( handlePressedKeyInMenu
|
||||
) where
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Debug.Terminal
|
||||
import Dodge.Menu
|
||||
|
||||
+17
-2
@@ -12,7 +12,6 @@ import Preload.Update
|
||||
import Dodge.Base.Window
|
||||
import Dodge.SoundLogic
|
||||
import Picture
|
||||
--import Geometry
|
||||
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
@@ -25,8 +24,9 @@ optionMenu = OptionScreen
|
||||
}
|
||||
optionsOptions :: [MenuOption]
|
||||
optionsOptions =
|
||||
[ Toggle ScancodeV (pushScreen soundMenu) (const "VOLUME")
|
||||
[ Toggle ScancodeV (pushScreen soundMenu) (const "VOLUME")
|
||||
, Toggle ScancodeG (pushScreen graphicsMenu) (const "GRAPHICS")
|
||||
, Toggle ScancodeP (pushScreen gameplayOptionsMenu) (const "GAMEPLAY")
|
||||
]
|
||||
levelMenuOptions :: [MenuOption]
|
||||
levelMenuOptions =
|
||||
@@ -34,6 +34,21 @@ levelMenuOptions =
|
||||
, InvisibleToggle ScancodeO (pushScreen optionMenu)
|
||||
, InvisibleToggle ScancodeC (pushScreen displayControls)
|
||||
]
|
||||
gameplayOptionsMenu :: ScreenLayer
|
||||
gameplayOptionsMenu = OptionScreen
|
||||
{ _scTitle = const "OPTIONS:GAMEPLAY"
|
||||
, _scOptions = gameplayMenuOptions
|
||||
, _scDefaultEff = popScreen . writeConfig
|
||||
, _scOptionFlag = NormalOptions
|
||||
}
|
||||
gameplayMenuOptions :: [MenuOption]
|
||||
gameplayMenuOptions =
|
||||
[ Toggle
|
||||
ScancodeR
|
||||
(Just . (config . rotate_to_wall %~ not))
|
||||
(\w -> "ROTATE TO WALL:" ++ show (_rotate_to_wall $ _config w))
|
||||
]
|
||||
|
||||
soundMenu :: ScreenLayer
|
||||
soundMenu = OptionScreen
|
||||
{ _scTitle = const "OPTIONS:VOLUME"
|
||||
|
||||
+8
-2
@@ -8,6 +8,7 @@ module Dodge.Update
|
||||
import Dodge.Data
|
||||
import Dodge.Menu
|
||||
import Dodge.Zone.Data
|
||||
import Dodge.Config.Data
|
||||
import Dodge.World.Trigger.Data
|
||||
--import Dodge.Config.Data
|
||||
import Dodge.Base
|
||||
@@ -60,7 +61,7 @@ functionalUpdate w = case _menuLayers w of
|
||||
. ppEvents
|
||||
. updateCamera
|
||||
. colCrsWalls
|
||||
. rotateToOverlappingWall
|
||||
. ifConfigWallRotate
|
||||
. simpleCrSprings
|
||||
. zoneCreatures
|
||||
. updateWalls
|
||||
@@ -252,6 +253,11 @@ crCrSpring c1 c2 w
|
||||
overlap2 = ((comRad - diff) * _crMass c1 * 0.5 / massT) *.* errorNormalizeV 56 vec
|
||||
massT = _crMass c1 + _crMass c2
|
||||
|
||||
ifConfigWallRotate :: World -> World
|
||||
ifConfigWallRotate w
|
||||
| _rotate_to_wall $ _config w = rotateToOverlappingWall w
|
||||
| otherwise = w
|
||||
|
||||
rotateToOverlappingWall :: World -> World
|
||||
rotateToOverlappingWall w = case theWall of
|
||||
Nothing -> w
|
||||
@@ -267,7 +273,7 @@ rotateToOverlappingWall w = case theWall of
|
||||
b' = fromIntegral $ (round b :: Int)
|
||||
cr = you w
|
||||
p = _crPos cr
|
||||
theWall = collideCircWallsReturnWall p (_crRad cr + 5) (wallsNearPoint p w)
|
||||
theWall = overlapCircWallsReturnWall p (_crRad cr + 5) (wallsNearPoint p w)
|
||||
|
||||
{-
|
||||
Finds the IDs of visible walls from a point to another point. -}
|
||||
|
||||
Reference in New Issue
Block a user