Cleanup and reorganise

This commit is contained in:
2021-10-31 19:46:32 +00:00
parent 41e64d14c3
commit 08fa84c1fd
53 changed files with 1352 additions and 1407 deletions
+15 -8
View File
@@ -1,5 +1,13 @@
{- | Getting the window size geometry. -}
module Dodge.Base.Window
( halfWidth
, halfHeight
, screenPolygon
, screenPolygonBord
, getWindowX
, getWindowY
, screenBox
)
where
import Dodge.Data
import Dodge.Config.Data
@@ -7,16 +15,17 @@ import Geometry
-- | A box covering the screen in world coordinates
screenPolygon :: World -> [Point2]
screenPolygon w = [tr,tl,bl,br]
screenPolygon w = map (scTran . scRot . scZoom) $ screenBox w
-- [tr,tl,bl,br]
where
scRot = rotateV (_cameraRot w)
scZoom p | _cameraZoom w /= 0 = (1/_cameraZoom w) *.* p
| otherwise = p
scTran p = p +.+ _cameraCenter w
tr = scTran $ scRot $ scZoom (V2 ( halfWidth w) ( halfHeight w))
tl = scTran $ scRot $ scZoom (V2 (-halfWidth w) ( halfHeight w))
br = scTran $ scRot $ scZoom (V2 ( halfWidth w) (-halfHeight w))
bl = scTran $ scRot $ scZoom (V2 (-halfWidth w) (-halfHeight w))
-- tr = scTran $ scRot $ scZoom (V2 ( halfWidth w) ( halfHeight w))
-- tl = scTran $ scRot $ scZoom (V2 (-halfWidth w) ( halfHeight w))
-- br = scTran $ scRot $ scZoom (V2 ( halfWidth w) (-halfHeight w))
-- bl = scTran $ scRot $ scZoom (V2 (-halfWidth w) (-halfHeight w))
-- | A box covering the screen in world coordinates, with a x and y border
screenPolygonBord
@@ -44,9 +53,7 @@ getWindowX = _windowX . _config
getWindowY = _windowY . _config
-- | A box of the size of the screen in screen centered coordinates
screenBox
:: World
-> [Point2]
screenBox :: World -> [Point2]
screenBox w = rectNSEW hh (-hh) hw (-hw)
where
hw = halfWidth w