Refactor map, add location arrows

This commit is contained in:
2021-03-26 03:13:18 +01:00
parent d79a8a862e
commit b46adf9898
8 changed files with 192 additions and 144 deletions
+16 -45
View File
@@ -26,43 +26,25 @@ import qualified Data.Map as M
import qualified Data.Set as S
worldPictures :: World -> Picture
worldPictures w
= pictures $ concat [ IM.elems $ _decorations w
, map _ptPict . IM.elems $ _projectiles w
, map drawItem . IM.elems $ _floorItems w
, map crDraw . IM.elems $ _creatures w
, map clDraw . IM.elems $ _clouds w
, map btDraw (IM.elems (_buttons w))
, map (\pt -> _ptDraw pt pt) $ _particles' w
, map drawWallFloor (wallFloorsToDraw w)
, testPic w
, mapOverlay w
]
worldPictures w = pictures $ concat
[ IM.elems $ _decorations w
, map _ptPict . IM.elems $ _projectiles w
, map drawItem . IM.elems $ _floorItems w
, map crDraw . IM.elems $ _creatures w
, map clDraw . IM.elems $ _clouds w
, map btDraw (IM.elems (_buttons w))
, map (\pt -> _ptDraw pt pt) $ _particles' w
, map drawWallFloor (wallFloorsToDraw w)
, testPic w
]
fixedCoordPictures :: World -> Picture
fixedCoordPictures w = pictures
[ scaler $ hudDrawings w
, scaler . onLayer MenuLayer $ menuScreen w
, setDepth (-1) $ closeObjectTexts w
]
where scaler = setDepth (-1) . scale (2 / _windowX w) (2 / _windowY w)
mapOverlay :: World -> [Picture]
mapOverlay w = case _mapDisplay w of
(True,mapZoom) -> (setLayer 1 . setDepth (-1) . color (withAlpha 0.5 black)
. polygon $ screenPolygon w)
:
(map ( setLayer 1 . setDepth (-1) . doZoom )
. mapMaybe mapWall
. IM.elems
$ _walls w
)
where
doZoom = uncurry translate (_cameraPos w)
. scale zoom zoom
. uncurry translate ((0,0) -.- _cameraPos w)
zoom = 2 * mapZoom / _cameraZoom w
_ -> []
[ hudDrawings w
, scaler . onLayer MenuLayer $ menuScreen w
]
where
scaler = setDepth (-1) . scale (2 / _windowX w) (2 / _windowY w)
testPic :: World -> [Picture]
testPic w = [blank]
@@ -78,17 +60,6 @@ clDraw :: Cloud -> Picture
clDraw c = uncurry translate (_clPos c) $ (_clPict c c)
mapWall :: Wall -> Maybe Picture
mapWall wl =
case _wlSeen wl of
False -> Nothing
True -> Just $ color c $ polygon [x,x +.+ n2,y +.+ n2, y]
where t = 5 *.* errorNormalizeV 68 (y -.- x)
n = vNormal t
n2 = 4 *.* n
(x:y:_) = _wlLine wl
c = _wlColor wl
wallFloorsToDraw :: World -> [Wall]
wallFloorsToDraw w = filter isVisible $ IM.elems $ wallsOnScreen w
where onScreen wall = lineOnScreen w (_wlLine wall)