Add view debug option
This commit is contained in:
@@ -20,6 +20,7 @@ data Configuration = Configuration
|
|||||||
, _debug_seconds_frame :: Bool
|
, _debug_seconds_frame :: Bool
|
||||||
, _debug_noclip :: Bool
|
, _debug_noclip :: Bool
|
||||||
, _debug_cr_status :: Bool
|
, _debug_cr_status :: Bool
|
||||||
|
, _debug_view_boundaries :: Bool
|
||||||
}
|
}
|
||||||
deriving (Generic, Show)
|
deriving (Generic, Show)
|
||||||
makeLenses ''Configuration
|
makeLenses ''Configuration
|
||||||
@@ -44,4 +45,5 @@ defaultConfig = Configuration
|
|||||||
, _debug_seconds_frame = True
|
, _debug_seconds_frame = True
|
||||||
, _debug_noclip = False
|
, _debug_noclip = False
|
||||||
, _debug_cr_status = False
|
, _debug_cr_status = False
|
||||||
|
, _debug_view_boundaries = False
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ generateLevelFromRoomList gr w
|
|||||||
. setupWorldBounds
|
. setupWorldBounds
|
||||||
-- . initializeStaticWalls
|
-- . initializeStaticWalls
|
||||||
-- . setupForegroundEdgeVerxs
|
-- . setupForegroundEdgeVerxs
|
||||||
. flip (foldr $ flip placeSpot') plmnts
|
. flip (foldr $ flip placeSpot) plmnts
|
||||||
-- . addRoomPolyDecorations rs
|
-- . addRoomPolyDecorations rs
|
||||||
-- . addRoomLinkDecorations rs
|
-- . addRoomLinkDecorations rs
|
||||||
$ w { _walls = wallsFromRooms rs
|
$ w { _walls = wallsFromRooms rs
|
||||||
|
|||||||
+7
-10
@@ -25,20 +25,17 @@ import qualified IntMapHelp as IM
|
|||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
placeSpot' :: World -> ((Point2,Float) , Placement) -> World
|
placeSpot :: World -> ((Point2,Float) , Placement) -> World
|
||||||
placeSpot' w (shift, plmnt) =
|
placeSpot w (shift, plmnt) =
|
||||||
let (i,w') = placeSpotID (shiftPSBy' shift (_placementSpot plmnt)) w
|
let (i,w') = placeSpotID (shiftPSBy shift (_placementSpot plmnt)) w
|
||||||
in maybe w' (curry (placeSpot' w') shift) (_idPlacement plmnt i)
|
in maybe w' (curry (placeSpot w') shift) (_idPlacement plmnt i)
|
||||||
|
|
||||||
shiftPlacement :: (Point2,Float) -> Placement -> Placement
|
shiftPlacement :: (Point2,Float) -> Placement -> Placement
|
||||||
shiftPlacement shift (Placement ps f) = Placement (shiftPSBy' shift ps)
|
shiftPlacement shift (Placement ps f) = Placement (shiftPSBy shift ps)
|
||||||
(fmap (fmap $ shiftPlacement shift) f)
|
(fmap (fmap $ shiftPlacement shift) f)
|
||||||
|
|
||||||
shiftPSBy'
|
shiftPSBy :: (Point2,Float) -> PlacementSpot -> PlacementSpot
|
||||||
:: (Point2,Float)
|
shiftPSBy (pos,rot) ps = ps
|
||||||
-> PlacementSpot
|
|
||||||
-> PlacementSpot
|
|
||||||
shiftPSBy' (pos,rot) ps = ps
|
|
||||||
& psPos %~ shiftPointBy (pos,rot)
|
& psPos %~ shiftPointBy (pos,rot)
|
||||||
& psRot %~ (+ rot)
|
& psRot %~ (+ rot)
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -44,18 +44,18 @@ debugOptionsMenu = OptionScreen
|
|||||||
}
|
}
|
||||||
debugMenuOptions :: [MenuOption]
|
debugMenuOptions :: [MenuOption]
|
||||||
debugMenuOptions =
|
debugMenuOptions =
|
||||||
[ Toggle
|
[ Toggle ScancodeF
|
||||||
ScancodeF
|
|
||||||
(Just . (config . debug_seconds_frame %~ not))
|
(Just . (config . debug_seconds_frame %~ not))
|
||||||
(\w -> "SHOW SECONDS/FRAME:" ++ show (_debug_seconds_frame $ _config w))
|
(\w -> "SHOW SECONDS/FRAME:" ++ show (_debug_seconds_frame $ _config w))
|
||||||
, Toggle
|
, Toggle ScancodeC
|
||||||
ScancodeC
|
|
||||||
(Just . (config . debug_noclip %~ not))
|
(Just . (config . debug_noclip %~ not))
|
||||||
(\w -> "NOCLIP:" ++ show (_debug_noclip $ _config w))
|
(\w -> "NOCLIP:" ++ show (_debug_noclip $ _config w))
|
||||||
, Toggle
|
, Toggle ScancodeS
|
||||||
ScancodeS
|
|
||||||
(Just . (config . debug_cr_status %~ not))
|
(Just . (config . debug_cr_status %~ not))
|
||||||
(\w -> "SHOW CREATURE STATUS:" ++ show (_debug_cr_status $ _config w))
|
(\w -> "SHOW CREATURE STATUS:" ++ show (_debug_cr_status $ _config w))
|
||||||
|
, Toggle ScancodeV
|
||||||
|
(Just . (config . debug_view_boundaries %~ not))
|
||||||
|
(\w -> "SHOW VIEW BOUNDARIES:" ++ show (_debug_view_boundaries $ _config w))
|
||||||
]
|
]
|
||||||
gameplayOptionsMenu :: ScreenLayer
|
gameplayOptionsMenu :: ScreenLayer
|
||||||
gameplayOptionsMenu = OptionScreen
|
gameplayOptionsMenu = OptionScreen
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import Dodge.Render.MenuScreen
|
|||||||
import Dodge.Render.ShapePicture
|
import Dodge.Render.ShapePicture
|
||||||
import Dodge.SoundLogic.LoadSound
|
import Dodge.SoundLogic.LoadSound
|
||||||
import Dodge.Config.Data
|
import Dodge.Config.Data
|
||||||
|
import Dodge.GameRoom
|
||||||
|
import Dodge.Update.Camera
|
||||||
import Sound.Data
|
import Sound.Data
|
||||||
import Geometry
|
import Geometry
|
||||||
import Picture
|
import Picture
|
||||||
@@ -40,6 +42,7 @@ worldPictures w = pictures
|
|||||||
,concatMapPic btDraw $ _buttons w
|
,concatMapPic btDraw $ _buttons w
|
||||||
,concatMapPic drawWallFloor $ wallFloorsToDraw w
|
,concatMapPic drawWallFloor $ wallFloorsToDraw w
|
||||||
,soundPics w
|
,soundPics w
|
||||||
|
,viewBoundaries w
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
crIsClose cr = dist (_crPos cr) camCen < winSize
|
crIsClose cr = dist (_crPos cr) camCen < winSize
|
||||||
@@ -74,12 +77,23 @@ testPic _ = []
|
|||||||
-- thepic = setDepth 20 . color green . polygon $ rectNSEW 5 (-5) (-5) (5)
|
-- thepic = setDepth 20 . color green . polygon $ rectNSEW 5 (-5) (-5) (5)
|
||||||
--testPic _ = blank
|
--testPic _ = blank
|
||||||
--testPic w = color green . pictures . map (flip thickLine 5 . tflat2) . graphToEdges $ _pathGraph w
|
--testPic w = color green . pictures . map (flip thickLine 5 . tflat2) . graphToEdges $ _pathGraph w
|
||||||
|
viewBoundaries :: World -> Picture
|
||||||
|
viewBoundaries w
|
||||||
|
| _debug_view_boundaries (_config w)
|
||||||
|
= setLayer 5 $ color green (concatMap (polygonWire . _grBound) grs)
|
||||||
|
<> color yellow (concatMap (\q -> line [p,q]) $ farWallPoints p w)
|
||||||
|
| otherwise = []
|
||||||
|
where
|
||||||
|
p = _crPos $ you w
|
||||||
|
grs = filter (pointInOrOnPolygon p . _grBound) (_gameRooms w)
|
||||||
|
|
||||||
soundPics :: World -> Picture
|
soundPics :: World -> Picture
|
||||||
soundPics w
|
soundPics w
|
||||||
| _show_sound (_config w) = pictures $ M.map (soundPic w) $ _playingSounds w
|
| _show_sound (_config w) = pictures $ M.map (soundPic w) $ _playingSounds w
|
||||||
| otherwise = []
|
| otherwise = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
soundPic :: World -> Sound -> Picture
|
soundPic :: World -> Sound -> Picture
|
||||||
soundPic w s = fixedSizePicClampArrow 50 50 thePic p w
|
soundPic w s = fixedSizePicClampArrow 50 50 thePic p w
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ the outgoing links.
|
|||||||
module Dodge.Room.Link
|
module Dodge.Room.Link
|
||||||
where
|
where
|
||||||
import Dodge.LevelGen
|
import Dodge.LevelGen
|
||||||
import Dodge.LevelGen.Data
|
|
||||||
import Dodge.Room.Data
|
import Dodge.Room.Data
|
||||||
import Dodge.RandomHelp
|
import Dodge.RandomHelp
|
||||||
import Geometry
|
import Geometry
|
||||||
--import Geometry.Data
|
|
||||||
import Data.Tile
|
import Data.Tile
|
||||||
|
|
||||||
import System.Random
|
import System.Random
|
||||||
@@ -84,15 +82,6 @@ shiftLinkBy
|
|||||||
-> (Point2,Float)
|
-> (Point2,Float)
|
||||||
shiftLinkBy (pos,rot) (p,r) = (shiftPointBy (pos,rot) p, r + rot)
|
shiftLinkBy (pos,rot) (p,r) = (shiftPointBy (pos,rot) p, r + rot)
|
||||||
|
|
||||||
shiftPSBy
|
|
||||||
:: (Point2,Float)
|
|
||||||
-> Placement
|
|
||||||
-> Placement
|
|
||||||
shiftPSBy (pos,rot) ps = ps
|
|
||||||
& placementSpot . psPos %~ shiftPointBy (pos,rot)
|
|
||||||
& placementSpot . psRot %~ (+ rot)
|
|
||||||
& idPlacement %~ fmap (fmap $ shiftPSBy (pos,rot))
|
|
||||||
|
|
||||||
shiftPathPointBy
|
shiftPathPointBy
|
||||||
:: (Point2,Float)
|
:: (Point2,Float)
|
||||||
-> (Point2,Point2)
|
-> (Point2,Point2)
|
||||||
|
|||||||
@@ -26,25 +26,18 @@ import Dodge.LevelGen
|
|||||||
import Dodge.LevelGen.Data
|
import Dodge.LevelGen.Data
|
||||||
import Dodge.LightSources.Fitting
|
import Dodge.LightSources.Fitting
|
||||||
import Dodge.Creature
|
import Dodge.Creature
|
||||||
--import Dodge.Default
|
|
||||||
import Geometry
|
import Geometry
|
||||||
import Geometry.Vector3D
|
import Geometry.Vector3D
|
||||||
import Picture
|
import Picture
|
||||||
import Data.Tile
|
import Data.Tile
|
||||||
|
|
||||||
--import Data.List
|
|
||||||
--import Data.Function (on)
|
|
||||||
--import qualified Data.Tuple.Extra as Tup
|
|
||||||
--import qualified Data.Map.Strict as M
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
import System.Random
|
import System.Random
|
||||||
{-
|
{- A simple rectangular room with a light in the center.
|
||||||
A simple rectangular room with a light in the center.
|
Creates links and pathfinding graph. -}
|
||||||
Creates links and pathfinding graph.
|
|
||||||
-}
|
|
||||||
roomRect
|
roomRect
|
||||||
:: Float -- ^ Width
|
:: Float -- ^ Width
|
||||||
-> Float -- ^ Height
|
-> Float -- ^ Height
|
||||||
@@ -73,9 +66,7 @@ roomRect x y xn yn = defaultRoom
|
|||||||
slnks = zip (translateS (V2 20 0) $ gridPoints xd (xn+1) 0 1 ) (repeat pi )
|
slnks = zip (translateS (V2 20 0) $ gridPoints xd (xn+1) 0 1 ) (repeat pi )
|
||||||
lnks = nlnks ++ elnks ++ wlnks ++ slnks
|
lnks = nlnks ++ elnks ++ wlnks ++ slnks
|
||||||
pth = linksAndPath lnks $ translateS (V2 20 20) (makeGrid xd xn yd yn)
|
pth = linksAndPath lnks $ translateS (V2 20 20) (makeGrid xd xn yd yn)
|
||||||
{-
|
{- Creates a rectangular room, automatically creates links and pathfinding graph at a sensible size. -}
|
||||||
Creates a rectangular room, automatically creates links and pathfinding graph at a sensible size.
|
|
||||||
-}
|
|
||||||
roomRectAutoLinks :: Float -> Float -> Room
|
roomRectAutoLinks :: Float -> Float -> Room
|
||||||
roomRectAutoLinks x y = roomRect x y ((ceiling x - 40) `div` 60) ((ceiling y - 40) `div` 60)
|
roomRectAutoLinks x y = roomRect x y ((ceiling x - 40) `div` 60) ((ceiling y - 40) `div` 60)
|
||||||
|
|
||||||
@@ -129,23 +120,12 @@ fourthWall w = do
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
pure $ defaultRoom
|
pure $ defaultRoom
|
||||||
{ _rmPolys = [ map toV2 [(0,0),(w,w),(-w,w)] ]
|
{ _rmPolys = [ [V2 0 0,V2 w w,V2 (-w) w] ]
|
||||||
, _rmLinks = [(V2 0 w, 0)]
|
, _rmLinks = [(V2 0 w, 0)]
|
||||||
, _rmPath = [(V2 0 w,V2 0 0),(V2 0 0,V2 0 w)]
|
, _rmPath = [(V2 0 w,V2 0 0),(V2 0 0,V2 0 w)]
|
||||||
, _rmPS = b
|
, _rmPS = b
|
||||||
, _rmBound = [[V2 0 0,V2 w w,V2 (-w) w]]
|
, _rmBound = [[V2 0 0,V2 w w,V2 (-w) w]]
|
||||||
}
|
}
|
||||||
--fourthCorner :: Float -> Room
|
|
||||||
--fourthCorner w = Room
|
|
||||||
-- { _rmPolys = [ [(0,0),(w,w),(0,2*w),(-w,w)] ]
|
|
||||||
-- , _rmLinks =
|
|
||||||
-- [((w/2,3*w/2), negate $ pi/4)
|
|
||||||
-- ,((negate $ w/2,3*w/2), pi/4)
|
|
||||||
-- ]
|
|
||||||
-- , _rmPath = [((0,w),(0,0)),((0,0),(0,w))]
|
|
||||||
-- , _rmPS = [sPS (0,w) 0 putLamp]
|
|
||||||
-- , _rmBound = [[(w,w),(0,2*w),(-w,w)]]
|
|
||||||
-- }
|
|
||||||
|
|
||||||
fourthCornerWall :: RandomGen g => Float -> State g Room
|
fourthCornerWall :: RandomGen g => Float -> State g Room
|
||||||
fourthCornerWall w = do
|
fourthCornerWall w = do
|
||||||
@@ -246,7 +226,7 @@ centerVaultRoom w h d = do
|
|||||||
]
|
]
|
||||||
++ map (\a -> mountedLightV (rotateV a $ V2 0 d) (rotate3z a $ V3 0 (d+30) 70))
|
++ map (\a -> mountedLightV (rotateV a $ V2 0 d) (rotate3z a $ V3 0 (d+30) 70))
|
||||||
[0,0.5*pi,pi,1.5*pi]
|
[0,0.5*pi,pi,1.5*pi]
|
||||||
++ concat (map (\r -> map (shiftPSBy (V2 0 0,r)) $ theDoor)
|
++ concat (map (\r -> map (shiftPlacement (V2 0 0,r)) $ theDoor)
|
||||||
[0,pi/2,pi,3*pi/2])
|
[0,pi/2,pi,3*pi/2])
|
||||||
, _rmBound = [rectNSWE h (-h) (-w) w]
|
, _rmBound = [rectNSWE h (-h) (-w) w]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user