diff options
| author | 3gg <3gg@shellblade.net> | 2022-09-18 17:18:03 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2022-09-18 17:18:03 -0700 |
| commit | d81c62adbc955855438f1626c685e92794017d2d (patch) | |
| tree | 2c01aca5f304aa810e39a9dd15b126a55841929b /demos/pong/Main.hs | |
| parent | 8f2ec33e8c15e523b2b60d3bfd8e6360313a0657 (diff) | |
Add App module.
Diffstat (limited to 'demos/pong/Main.hs')
| -rw-r--r-- | demos/pong/Main.hs | 15 |
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) | |||
| 4 | import Graphics.Rendering.OpenGL.GL (($=)) | 4 | import Graphics.Rendering.OpenGL.GL (($=)) |
| 5 | import qualified Graphics.Rendering.OpenGL.GL as GL | 5 | import qualified Graphics.Rendering.OpenGL.GL as GL |
| 6 | import Pong | 6 | import Pong |
| 7 | import Spear.App | ||
| 7 | import Spear.Game | 8 | import Spear.Game |
| 8 | import Spear.Math.AABB | 9 | import Spear.Math.AABB |
| 9 | import Spear.Math.Spatial2 | 10 | import 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 | ||
| 30 | step :: Elapsed -> Dt -> Game GameState Bool | 31 | step :: Elapsed -> Dt -> [InputEvent] -> Game GameState Bool |
| 31 | step elapsed dt = do | 32 | step 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 | ||
| 44 | render world = do | 43 | render world = do |
| 45 | GL.clear [GL.ColorBuffer] | 44 | GL.clear [GL.ColorBuffer] |
