Load window size from config into world

This commit is contained in:
jgk
2021-03-22 23:06:19 +01:00
parent e296e5d841
commit 257e60e4e8
3 changed files with 15 additions and 21 deletions
+5 -11
View File
@@ -34,25 +34,15 @@ import qualified SDL as SDL
import qualified SDL.Mixer as Mix
import Graphics.Rendering.OpenGL hiding (color,scale,translate,rotate)
initWorld = initialWorld
{ _randGen = mkStdGen 2
, _windowX = 800
, _windowY = 600
}
pps = [(0,0),(50,0),(0,25)]
ppt = [(0,0),(-0.50,0),(0.20,0.25)]
main :: IO ()
main = do
-- loadedSounds <- loadSounds
(sizex,sizey) <- loadConfig
setupLoop
"windowName"
sizex sizey
(doPreload >>= resizeSpareFBO sizex sizey)
cleanUpPreload
(initializeWorld $ generateFromTree lev1 $ initWorld)
(fmap (setWindowSize sizex sizey) firstWorld)
( \preData w -> do
startTicks <- SDL.ticks
(lightTicks,timeSpentPoking) <- renderPicture' (_renderData preData)
@@ -80,3 +70,7 @@ main = do
(flip $ menuEvents $ flip handleEvent)
(\w -> Just $ update w)
Mix.closeAudio
setWindowSize :: Int -> Int -> World -> World
setWindowSize x y w = w & windowX .~ fromIntegral x
& windowY .~ fromIntegral y