From 85da1895b865cf68300c9a2299a113cee0aa1cbd Mon Sep 17 00:00:00 2001 From: Jeanne-Kamikaze Date: Mon, 23 Dec 2013 01:17:43 +0100 Subject: Window module now tracks elapsed time --- demos/pong/Main.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'demos/pong/Main.hs') diff --git a/demos/pong/Main.hs b/demos/pong/Main.hs index e9a6dc1..d0664b7 100644 --- a/demos/pong/Main.hs +++ b/demos/pong/Main.hs @@ -14,7 +14,6 @@ import Graphics.Rendering.OpenGL.GL (($=)) data GameState = GameState { wnd :: Window - , elapsed :: Double , world :: [GameObject] } @@ -27,17 +26,16 @@ initGame wnd = do GL.clearColor $= GL.Color4 0.7 0.5 0.7 1.0 GL.matrixMode $= GL.Modelview 0 GL.loadIdentity - return $ GameState wnd 0 newWorld + return $ GameState wnd newWorld -step :: Dt -> Game GameState Bool -step dt = do +step :: Elapsed -> Dt -> Game GameState Bool +step elapsed dt = do gs <- getGameState evts <- events (wnd gs) gameIO . process $ evts let evts' = translate evts modifyGameState $ \ gs -> gs - { world = stepWorld (elapsed gs) dt evts' (world gs) - , elapsed = elapsed gs + realToFrac dt } + { world = stepWorld elapsed dt evts' (world gs) } getGameState >>= \gs -> gameIO . render $ world gs return (not $ exitRequested evts) @@ -78,4 +76,4 @@ translate' _ = Nothing exitRequested = any (==(KeyDown KEY_ESC)) f2d :: Float -> GL.GLdouble -f2d = realToFrac \ No newline at end of file +f2d = realToFrac -- cgit v1.2.3