This commit is contained in:
2021-11-28 22:38:26 +00:00
parent 8c5777a1af
commit 8832a73d86
9 changed files with 21 additions and 24 deletions
+4 -6
View File
@@ -6,6 +6,7 @@ Consider splitting. -}
module Dodge.Base
where
import Dodge.Data
import Dodge.WinScale
import Dodge.Zone
--import Dodge.Zone.Data
import Dodge.Base.Window
@@ -458,8 +459,8 @@ worldPosToScreenNorm cfig w = doWindowScale . doRotate . doZoom . doTranslate
doZoom p = _cameraZoom w *.* p
doRotate p = rotateV (negate $ _cameraRot w) p
doWindowScale (V2 x y) = V2
( x * 2 / getWindowX cfig)
( y * 2 / getWindowY cfig)
( x * 2 / _windowX cfig)
( y * 2 / _windowY cfig)
{- | Transform world coordinates to scaled screen coordinates.
- These have to be according to the size of the window to get actual screen positions.
- This allows for line thicknesses etc to correspond to pixel sizes.-}
@@ -472,14 +473,11 @@ worldPosToScreen w = doRotate . doZoom . doTranslate
{- | Transform coordinates from the map position to screen
coordinates. -}
cartePosToScreen :: Configuration -> World -> Point2 -> Point2
cartePosToScreen cfig w = doWindowScale . doRotate . doZoom . doTranslate
cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
where
doTranslate p = p -.- _carteCenter w
doZoom p = _carteZoom w *.* p
doRotate p = rotateV (negate $ _carteRot w) p
doWindowScale (V2 x y) = V2
( x * 2 / getWindowX cfig)
( y * 2 / getWindowY cfig)
{- | The mouse position in world coordinates. -}
mouseWorldPos :: World -> Point2
mouseWorldPos w = _cameraCenter w +.+ (1/_cameraZoom w) *.* rotateV (_cameraRot w) (_mousePos w)