aboutsummaryrefslogtreecommitdiff
path: root/demos/pong/Main.hs
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2022-09-18 17:18:03 -0700
committer3gg <3gg@shellblade.net>2022-09-18 17:18:03 -0700
commitd81c62adbc955855438f1626c685e92794017d2d (patch)
tree2c01aca5f304aa810e39a9dd15b126a55841929b /demos/pong/Main.hs
parent8f2ec33e8c15e523b2b60d3bfd8e6360313a0657 (diff)
Add App module.
Diffstat (limited to 'demos/pong/Main.hs')
-rw-r--r--demos/pong/Main.hs15
1 files changed, 7 insertions, 8 deletions
diff --git a/demos/pong/Main.hs b/demos/pong/Main.hs
index 3563c30..a9dfcdd 100644
--- a/demos/pong/Main.hs
+++ b/demos/pong/Main.hs
@@ -4,6 +4,7 @@ import Data.Maybe (mapMaybe)
4import Graphics.Rendering.OpenGL.GL (($=)) 4import Graphics.Rendering.OpenGL.GL (($=))
5import qualified Graphics.Rendering.OpenGL.GL as GL 5import qualified Graphics.Rendering.OpenGL.GL as GL
6import Pong 6import Pong
7import Spear.App
7import Spear.Game 8import Spear.Game
8import Spear.Math.AABB 9import Spear.Math.AABB
9import Spear.Math.Spatial2 10import Spear.Math.Spatial2
@@ -27,19 +28,17 @@ initGame window = do
27 GL.loadIdentity 28 GL.loadIdentity
28 return $ GameState window newWorld 29 return $ GameState window newWorld
29 30
30step :: Elapsed -> Dt -> Game GameState Bool 31step :: Elapsed -> Dt -> [InputEvent] -> Game GameState Bool
31step elapsed dt = do 32step elapsed dt inputEvents = do
32 --gameIO $ putStrLn "Tick"
33 gs <- getGameState 33 gs <- getGameState
34 evts <- events (window gs) 34 gameIO . process $ inputEvents
35 gameIO . process $ evts 35 let events = translate inputEvents
36 let evts' = translate evts
37 modifyGameState $ \gs -> 36 modifyGameState $ \gs ->
38 gs 37 gs
39 { world = stepWorld elapsed dt evts' (world gs) 38 { world = stepWorld elapsed dt events (world gs)
40 } 39 }
41 getGameState >>= \gs -> gameIO . render $ world gs 40 getGameState >>= \gs -> gameIO . render $ world gs
42 return (not $ exitRequested evts) 41 return (not $ exitRequested inputEvents)
43 42
44render world = do 43render world = do
45 GL.clear [GL.ColorBuffer] 44 GL.clear [GL.ColorBuffer]