diff options
author | 3gg <3gg@shellblade.net> | 2023-03-10 09:30:47 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-03-10 09:30:47 -0800 |
commit | b2b0e12c212a40ef2469f77043573b5569ff9e6d (patch) | |
tree | 2143488908f04414e74f6c36f0e373982f27d32c /Demos/Pong/Main.hs | |
parent | 6e26564f4235eeea5dda386282e18081db6f8f07 (diff) |
Minor refactoring and formatting.
Diffstat (limited to 'Demos/Pong/Main.hs')
-rw-r--r-- | Demos/Pong/Main.hs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/Demos/Pong/Main.hs b/Demos/Pong/Main.hs index 4dbe0a3..ee0f8d8 100644 --- a/Demos/Pong/Main.hs +++ b/Demos/Pong/Main.hs | |||
@@ -2,20 +2,20 @@ | |||
2 | 2 | ||
3 | module Main where | 3 | module Main where |
4 | 4 | ||
5 | import Data.Maybe (mapMaybe) | 5 | import Data.Maybe (mapMaybe) |
6 | import Graphics.Rendering.OpenGL.GL (($=)) | 6 | import Graphics.Rendering.OpenGL.GL (($=)) |
7 | import Graphics.Rendering.OpenGL.GL qualified as GL | 7 | import qualified Graphics.Rendering.OpenGL.GL as GL |
8 | import Pong | 8 | import Pong |
9 | import Spear.App | 9 | import Spear.App |
10 | import Spear.Game | 10 | import Spear.Game |
11 | import Spear.Math.AABB | 11 | import Spear.Math.AABB |
12 | import Spear.Math.Spatial2 | 12 | import Spear.Math.Spatial2 |
13 | import Spear.Math.Vector | 13 | import Spear.Math.Vector |
14 | import Spear.Window | 14 | import Spear.Window |
15 | 15 | ||
16 | data GameState = GameState | 16 | data GameState = GameState |
17 | { window :: Window, | 17 | { window :: Window, |
18 | world :: [GameObject] | 18 | world :: [GameObject] |
19 | } | 19 | } |
20 | 20 | ||
21 | main = | 21 | main = |
@@ -53,7 +53,7 @@ renderGO go = do | |||
53 | (xmin, ymin, xmax, ymax) = (f2d xmin', f2d ymin', f2d xmax', f2d ymax') | 53 | (xmin, ymin, xmax, ymax) = (f2d xmin', f2d ymin', f2d xmax', f2d ymax') |
54 | GL.preservingMatrix $ do | 54 | GL.preservingMatrix $ do |
55 | GL.translate (GL.Vector3 (f2d xcenter) (f2d ycenter) 0) | 55 | GL.translate (GL.Vector3 (f2d xcenter) (f2d ycenter) 0) |
56 | GL.renderPrimitive (GL.TriangleStrip) $ do | 56 | GL.renderPrimitive GL.TriangleStrip $ do |
57 | GL.vertex (GL.Vertex2 xmin ymax) | 57 | GL.vertex (GL.Vertex2 xmin ymax) |
58 | GL.vertex (GL.Vertex2 xmin ymin) | 58 | GL.vertex (GL.Vertex2 xmin ymin) |
59 | GL.vertex (GL.Vertex2 xmax ymax) | 59 | GL.vertex (GL.Vertex2 xmax ymax) |
@@ -71,13 +71,13 @@ procEvent _ = return () | |||
71 | 71 | ||
72 | translate = mapMaybe translate' | 72 | translate = mapMaybe translate' |
73 | 73 | ||
74 | translate' (KeyDown KEY_LEFT) = Just MoveLeft | 74 | translate' (KeyDown KEY_LEFT) = Just MoveLeft |
75 | translate' (KeyDown KEY_RIGHT) = Just MoveRight | 75 | translate' (KeyDown KEY_RIGHT) = Just MoveRight |
76 | translate' (KeyUp KEY_LEFT) = Just StopLeft | 76 | translate' (KeyUp KEY_LEFT) = Just StopLeft |
77 | translate' (KeyUp KEY_RIGHT) = Just StopRight | 77 | translate' (KeyUp KEY_RIGHT) = Just StopRight |
78 | translate' _ = Nothing | 78 | translate' _ = Nothing |
79 | 79 | ||
80 | exitRequested = any (== (KeyDown KEY_ESC)) | 80 | exitRequested = elem (KeyDown KEY_ESC) |
81 | 81 | ||
82 | f2d :: Float -> GL.GLdouble | 82 | f2d :: Float -> GL.GLdouble |
83 | f2d = realToFrac | 83 | f2d = realToFrac |