Cleanup. Start tweaking flares, glares and flashes
This commit is contained in:
+17
-22
@@ -1,4 +1,6 @@
|
||||
module Main where
|
||||
module Main
|
||||
( main
|
||||
) where
|
||||
import Loop
|
||||
import Dodge.Data
|
||||
import Dodge.Initialisation
|
||||
@@ -31,6 +33,7 @@ import qualified Data.Map.Strict as M
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
-- load the config to get the window size and position
|
||||
con <- loadDodgeConfig
|
||||
let sizex = floor $ _windowX con
|
||||
sizey = floor $ _windowY con
|
||||
@@ -39,22 +42,21 @@ main = do
|
||||
setupLoop
|
||||
20
|
||||
(sizex,sizey)
|
||||
(posx,posy)
|
||||
(Just (posx,posy))
|
||||
theCleanup
|
||||
(firstWorldLoad (sizex,sizey))
|
||||
(firstWorldLoad con)
|
||||
theUpdateStep
|
||||
(flip handleEvent)
|
||||
|
||||
theCleanup :: World -> IO ()
|
||||
theCleanup w = SDL.cursorVisible $= True >> cleanUpPreload (_preloadData w)
|
||||
|
||||
firstWorldLoad :: (Int,Int) -> IO World
|
||||
firstWorldLoad (sizex,sizey) = do
|
||||
firstWorldLoad :: Configuration -> IO World
|
||||
firstWorldLoad theConfig = do
|
||||
SDL.cursorVisible $= False
|
||||
theKeyConfig <- loadKeyConfig
|
||||
theConfig <- loadDodgeConfig
|
||||
pdata <- doPreload >>= applyWorldConfig theConfig
|
||||
w <- fmap (setWindowSize sizex sizey . (keyConfig .~ theKeyConfig) . (config .~ theConfig)) firstWorld
|
||||
w <- fmap ((keyConfig .~ theKeyConfig) . (config .~ theConfig)) firstWorld
|
||||
return $ w & preloadData .~ pdata
|
||||
|
||||
theUpdateStep :: World -> IO World
|
||||
@@ -88,25 +90,18 @@ doSideEffects w = do
|
||||
|
||||
doPreload :: IO PreloadData
|
||||
doPreload = do
|
||||
rData <- preloadRender
|
||||
lChunks <- loadSounds
|
||||
lMusic <- loadMusic
|
||||
let sData = SoundData {_loadedChunks = lChunks}
|
||||
mData = MusicData {_loadedMusic = lMusic}
|
||||
Mix.playMusic Mix.Forever (lMusic IM.! 0)
|
||||
rData <- preloadRender
|
||||
return $ PreloadData
|
||||
return PreloadData
|
||||
{ _renderData = rData
|
||||
, _soundData = sData
|
||||
, _musicData = mData
|
||||
, _soundData = SoundData {_loadedChunks = lChunks}
|
||||
, _musicData = MusicData {_loadedMusic = lMusic}
|
||||
, _frameTimer = 0
|
||||
}
|
||||
|
||||
checkForGlErrors :: IO ()
|
||||
checkForGlErrors = do
|
||||
errs <- errors
|
||||
unless (null errs) $ putStrLn $ "GLerror during doLoop: " ++ unwords (map show errs)
|
||||
|
||||
setWindowSize :: Int -> Int -> World -> World
|
||||
setWindowSize x y w = w
|
||||
& config . windowX .~ fromIntegral x
|
||||
& config . windowY .~ fromIntegral y
|
||||
--checkForGlErrors :: IO ()
|
||||
--checkForGlErrors = do
|
||||
-- errs <- errors
|
||||
-- unless (null errs) $ putStrLn $ "GLerror during doLoop: " ++ unwords (map show errs)
|
||||
|
||||
Reference in New Issue
Block a user