Minor tweaking, argument refining

This commit is contained in:
2022-10-29 12:20:19 +01:00
parent af6cdff063
commit afaef480db
17 changed files with 59 additions and 56 deletions
+9 -9
View File
@@ -6,7 +6,10 @@ module Dodge.Base.Coordinate (
import Control.Lens
import Dodge.Base.WinScale
import Dodge.Data.Universe
import Dodge.Data.CamPos
import Dodge.Data.Config
import Dodge.Data.HUD
import Dodge.Data.Input
import Geometry
---- | Transform coordinates from world position to screen coordinates.
@@ -30,10 +33,9 @@ worldPosToScreen cam =
{- | Transform coordinates from the map position to screen
coordinates.
-}
cartePosToScreen :: Configuration -> World -> Point2 -> Point2
cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
cartePosToScreen :: Configuration -> HUD -> Point2 -> Point2
cartePosToScreen cfig thehud = doWindowScale cfig . doRotate . doZoom . doTranslate
where
thehud = w ^. cWorld . lWorld . hud
doTranslate p = p -.- (thehud ^. carteCenter) -- _carteCenter (_hud (_cWorld w))
doZoom p = (thehud ^. carteZoom) *.* p
doRotate p = rotateV (negate $ thehud ^. carteRot) p
@@ -42,12 +44,10 @@ cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
--crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr, 0)
-- | The mouse position in world coordinates.
mouseWorldPos :: World -> Point2
mouseWorldPos w =
mouseWorldPos :: Input -> CamPos -> Point2
mouseWorldPos inp cam =
(cam ^. camCenter)
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) (_mousePos $ _input w)
where
cam = w ^. cWorld . lWorld . camPos
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) (_mousePos inp)
---- | The mouse position in map coordinates
--mouseCartePos :: World -> Point2