Move configuration from world to universe
This commit is contained in:
+11
-10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user