More camera refactor

This commit is contained in:
2022-10-28 21:22:44 +01:00
parent 2e7cd0aec2
commit 32744d7cb3
5 changed files with 18 additions and 13 deletions
+7 -3
View File
@@ -22,9 +22,9 @@ targetSimpleDraw = targetDraw $ const activeTargetCursorPic
targetDistanceDraw :: Item -> Creature -> Configuration -> World -> Picture
targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do
p <- itm ^? itTargeting . tgPos . _Just
let p1 = worldPosToScreen w p
let p1 = worldPosToScreen cam p
mwp = mouseWorldPos w
p2 = worldPosToScreen w mwp
p2 = worldPosToScreen cam mwp
thecol = if dist p mwp > 100 then red else white
return $
winScale cfig $
@@ -32,6 +32,8 @@ targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do
color thecol $
line [p1, p2]
<> transMidLine p1 p2 (scale 0.1 0.1 . text . shortShow $ dist p mwp)
where
cam = w ^. cWorld . lWorld . camPos
targetDraw :: (Item -> Picture) -> Item -> Creature -> Configuration -> World -> Picture
targetDraw f it _ cfig w = fromMaybe mempty $ do
@@ -40,8 +42,10 @@ targetDraw f it _ cfig w = fromMaybe mempty $ do
winScale cfig $
setLayer FixedCoordLayer $
color white $
uncurryV translate (worldPosToScreen w p) $
uncurryV translate (worldPosToScreen cam p) $
f it
where
cam = w ^. cWorld . lWorld . camPos
activeTargetCursorPic :: Picture
activeTargetCursorPic =