This commit is contained in:
2025-06-24 08:48:08 +01:00
parent 5537efe584
commit 366b998989
10 changed files with 25 additions and 28 deletions
+5 -8
View File
@@ -2,7 +2,7 @@ module Dodge.Base.Coordinate (
cartePosToScreen,
worldPosToScreen,
screenToWorldPos,
mouseWorldPos',
mouseWorldPos,
) where
import Control.Lens
@@ -37,7 +37,7 @@ coordinates.
cartePosToScreen :: HUD -> Point2 -> Point2
cartePosToScreen thehud = doRotate . doZoom . doTranslate
where
doTranslate p = p -.- (thehud ^. carteCenter) -- _carteCenter (_hud (_cWorld w))
doTranslate p = p - (thehud ^. carteCenter) -- _carteCenter (_hud (_cWorld w))
doZoom p = (thehud ^. carteZoom) *.* p
doRotate p = rotateV (negate $ thehud ^. carteRot) p
@@ -45,16 +45,13 @@ cartePosToScreen thehud = doRotate . doZoom . doTranslate
--crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr, 0)
-- | The mouse position in world coordinates.
mouseWorldPos' :: Input -> Camera -> Point2
mouseWorldPos' inp cam =
(cam ^. camCenter)
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) (_mousePos inp)
mouseWorldPos :: Input -> Camera -> Point2
mouseWorldPos inp cam = screenToWorldPos cam (inp ^. mousePos)
screenToWorldPos :: Camera -> Point2 -> Point2
screenToWorldPos cam p =
(cam ^. camCenter)
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) p
+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) p
---- | The mouse position in map coordinates
--mouseCartePos :: World -> Point2