Move configuration from world to universe

This commit is contained in:
2021-11-28 22:30:47 +00:00
parent 45ba120796
commit 8c5777a1af
29 changed files with 343 additions and 300 deletions
+11 -10
View File
@@ -13,8 +13,8 @@ import Dodge.Data
import Geometry
-- | A box covering the screen in world coordinates
screenPolygon :: World -> [Point2]
screenPolygon w = map (scTran . scRot . scZoom) $ screenBox w
screenPolygon :: Configuration -> World -> [Point2]
screenPolygon cfig w = map (scTran . scRot . scZoom) $ screenBox cfig
-- [tr,tl,bl,br]
where
scRot = rotateV (_cameraRot w)
@@ -30,12 +30,13 @@ screenPolygon w = map (scTran . scRot . scZoom) $ screenBox w
screenPolygonBord
:: Float -- ^ X border
-> Float -- ^ Y border
-> Configuration
-> World
-> [Point2]
screenPolygonBord xbord ybord w = [tr,tl,bl,br]
screenPolygonBord xbord ybord cfig w = [tr,tl,bl,br]
where
hw = halfWidth w - xbord
hh = halfHeight w - ybord
hw = halfWidth cfig - xbord
hh = halfHeight cfig - ybord
scZoom p | _cameraZoom w /= 0 = (1/_cameraZoom w) *.* p
| otherwise = p
theTransform = (+.+ _cameraCenter w) . rotateV (_cameraRot w) . scZoom
@@ -44,15 +45,15 @@ screenPolygonBord xbord ybord w = [tr,tl,bl,br]
br = theTransform (V2 hw (-hh))
bl = theTransform (V2 (-hw) (-hh))
halfWidth,halfHeight :: World -> Float
halfWidth,halfHeight :: Configuration -> Float
halfWidth w = getWindowX w / 2
halfHeight w = getWindowY w / 2
getWindowX ,getWindowY :: World -> Float
getWindowX = _windowX . _config
getWindowY = _windowY . _config
getWindowX ,getWindowY :: Configuration -> Float
getWindowX = _windowX
getWindowY = _windowY
-- | A box of the size of the screen in screen centered coordinates
screenBox :: World -> [Point2]
screenBox :: Configuration -> [Point2]
screenBox w = rectNSEW hh (-hh) hw (-hw)
where
hw = halfWidth w