Allow for parameters to be changed by io actions
This commit is contained in:
+2
-1
@@ -51,12 +51,14 @@ main = do
|
||||
(initializeWorld $ generateFromTree lev1 $ initWorld)
|
||||
(-- \((bs:fs:ts:_),tes) w -> --do render setparams w egFade
|
||||
\preData w -> --do render setparams w egFade
|
||||
do
|
||||
renderPicture' preData (_cameraRot w) (_cameraZoom w)
|
||||
(_cameraPos w)
|
||||
(_windowX w,_windowY w)
|
||||
(wallsForGloom' w)
|
||||
(lightsForGloom' w)
|
||||
(draw blank w)
|
||||
return preData
|
||||
--renderPicture' preData (_windowX w,_windowY w) (Circle 5)
|
||||
-- renderPicture' preData
|
||||
-- (pictures [scale 0.5 0.9 $ polygon [(0,0),(0,-0.5),(-0.5,-0.5),(-0.5,0.0)]
|
||||
@@ -65,7 +67,6 @@ main = do
|
||||
-- ]
|
||||
-- )
|
||||
)
|
||||
(\_ _ -> return)
|
||||
(flip $ menuEvents $ flip handleEvent)
|
||||
(\w -> Just $ update w)
|
||||
Mix.closeAudio
|
||||
|
||||
+5
-7
@@ -28,13 +28,12 @@ setupLoop :: String
|
||||
-> IO setupParams
|
||||
-> (setupParams -> IO ())
|
||||
-> world
|
||||
-> (setupParams -> world -> IO ())
|
||||
-> (setupParams -> world -> storableSideEffects -> IO storableSideEffects)
|
||||
-> (setupParams -> world -> IO setupParams)
|
||||
-> (world -> Event -> Maybe world)
|
||||
-> (world -> Maybe world)
|
||||
-> IO ()
|
||||
setupLoop wName xSize ySize
|
||||
customInit initCleanup startWorld sideEffects storableFn eventFn worldFn = do
|
||||
customInit initCleanup startWorld sideEffects eventFn worldFn = do
|
||||
initializeAll
|
||||
bracket (createWindow (T.pack wName) (winConfig xSize ySize)) destroyWindow
|
||||
(\window ->
|
||||
@@ -48,7 +47,7 @@ setupLoop wName xSize ySize
|
||||
GL.clearColor $= GL.Color4 0 0.5 0 1
|
||||
GL.clearDepth $= (200)
|
||||
doLoop setup window startWorld
|
||||
sideEffects storableFn eventFn worldFn
|
||||
sideEffects eventFn worldFn
|
||||
)
|
||||
)
|
||||
|
||||
@@ -60,12 +59,11 @@ setupLoop wName xSize ySize
|
||||
-- -> IO ()
|
||||
doLoop setup window startWorld
|
||||
worldSideEffects
|
||||
storableFn
|
||||
eventFn
|
||||
worldUpdate
|
||||
= do
|
||||
GL.clear [GL.ColorBuffer,GL.DepthBuffer]
|
||||
worldSideEffects setup startWorld
|
||||
newParams <- worldSideEffects setup startWorld
|
||||
glSwapWindow window
|
||||
--worldSideEffects setup updatedWorld
|
||||
startLoopTicks <- ticks
|
||||
@@ -83,7 +81,7 @@ doLoop setup window startWorld
|
||||
endLoopTicks <- ticks -- it might be better to use System.Clock (monotonic)
|
||||
let delay = max 0 (10 + fromIntegral startLoopTicks - fromIntegral endLoopTicks)
|
||||
threadDelay (delay * 1000)
|
||||
doLoop setup window updatedWorld worldSideEffects storableFn eventFn worldUpdate
|
||||
doLoop newParams window updatedWorld worldSideEffects eventFn worldUpdate
|
||||
Nothing -> return ()
|
||||
|
||||
applyEvents :: (world0 -> Event -> Maybe world0)
|
||||
|
||||
Reference in New Issue
Block a user