Put config/targeting pictures in sensible places, tweak main loop

This commit is contained in:
2022-06-28 01:19:47 +01:00
parent 03b37c4e7b
commit f6d96ec92c
14 changed files with 148 additions and 154 deletions
+21 -4
View File
@@ -24,6 +24,8 @@ import Data.Preload.Render
import Control.Lens
import Control.Monad
--import Control.Monad.Parallel
import qualified Data.Text as T
import qualified Data.IntMap as IM
import Graphics.Rendering.OpenGL hiding (color, rotate, scale, translate)
import qualified SDL
@@ -41,13 +43,29 @@ main = do
posy = _windowPosY con
setupLoop
20
(sizex,sizey)
(Just (posx,posy))
(T.pack "Simple Game Loop")
(winConfig sizex sizey (Just (posx,posy)))
theCleanup
(firstWorldLoad con)
theUpdateStep
(flip handleEvent)
-- | Create an OpenGL SDL window configuration with a given x and y size.
winConfig :: Int -> Int -> Maybe (Int, Int) -> SDL.WindowConfig
winConfig x y winpos = SDL.defaultWindow
{ SDL.windowGraphicsContext = SDL.OpenGLContext $ SDL.defaultOpenGL
{ SDL.glProfile = SDL.Core SDL.Normal 4 3
, SDL.glColorPrecision = SDL.V4 8 8 8 8
}
, SDL.windowPosition = theWinPos
, SDL.windowInitialSize = SDL.V2 (fromIntegral x) (fromIntegral y)
, SDL.windowResizable = True
}
where
theWinPos = case winpos of
Just (px,py) -> SDL.Absolute (SDL.P (SDL.V2 (fromIntegral px) (fromIntegral py)))
Nothing -> SDL.Wherever
theCleanup :: Universe -> IO ()
theCleanup uv = SDL.cursorVisible $= True >> cleanUpPreload (_preloadData uv)
@@ -56,7 +74,6 @@ firstWorldLoad theConfig = do
SDL.cursorVisible $= False
theKeyConfig <- loadKeyConfig
pdata <- doPreload >>= applyWorldConfig theConfig
-- w <- generateWorldFromSeed 0
return $ startNewGame $ Universe
{_uvWorld = initialWorld
,_config = theConfig
@@ -73,7 +90,7 @@ updateRenderSplit :: Universe -> IO Universe
updateRenderSplit u = do
let preData = _preloadData u
updateUniverse u `par` void (doDrawing (_renderData preData) u)
return $ updateUniverse u
return (updateUniverse u)
playSoundUnlessRewinding :: Universe -> IO (M.Map SoundOrigin Sound)
playSoundUnlessRewinding u