aboutsummaryrefslogtreecommitdiff
path: root/demos/pong
diff options
context:
space:
mode:
Diffstat (limited to 'demos/pong')
-rw-r--r--demos/pong/Main.hs12
1 files changed, 5 insertions, 7 deletions
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 (($=))
14 14
15data GameState = GameState 15data GameState = GameState
16 { wnd :: Window 16 { wnd :: Window
17 , elapsed :: Double
18 , world :: [GameObject] 17 , world :: [GameObject]
19 } 18 }
20 19
@@ -27,17 +26,16 @@ initGame wnd = do
27 GL.clearColor $= GL.Color4 0.7 0.5 0.7 1.0 26 GL.clearColor $= GL.Color4 0.7 0.5 0.7 1.0
28 GL.matrixMode $= GL.Modelview 0 27 GL.matrixMode $= GL.Modelview 0
29 GL.loadIdentity 28 GL.loadIdentity
30 return $ GameState wnd 0 newWorld 29 return $ GameState wnd newWorld
31 30
32step :: Dt -> Game GameState Bool 31step :: Elapsed -> Dt -> Game GameState Bool
33step dt = do 32step elapsed dt = do
34 gs <- getGameState 33 gs <- getGameState
35 evts <- events (wnd gs) 34 evts <- events (wnd gs)
36 gameIO . process $ evts 35 gameIO . process $ evts
37 let evts' = translate evts 36 let evts' = translate evts
38 modifyGameState $ \ gs -> gs 37 modifyGameState $ \ gs -> gs
39 { world = stepWorld (elapsed gs) dt evts' (world gs) 38 { world = stepWorld elapsed dt evts' (world gs) }
40 , elapsed = elapsed gs + realToFrac dt }
41 getGameState >>= \gs -> gameIO . render $ world gs 39 getGameState >>= \gs -> gameIO . render $ world gs
42 return (not $ exitRequested evts) 40 return (not $ exitRequested evts)
43 41
@@ -78,4 +76,4 @@ translate' _ = Nothing
78exitRequested = any (==(KeyDown KEY_ESC)) 76exitRequested = any (==(KeyDown KEY_ESC))
79 77
80f2d :: Float -> GL.GLdouble 78f2d :: Float -> GL.GLdouble
81f2d = realToFrac \ No newline at end of file 79f2d = realToFrac