aboutsummaryrefslogtreecommitdiff
path: root/Demos/Pong/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Pong/Main.hs')
-rw-r--r--Demos/Pong/Main.hs34
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
3module Main where 3module Main where
4 4
5import Data.Maybe (mapMaybe) 5import Data.Maybe (mapMaybe)
6import Graphics.Rendering.OpenGL.GL (($=)) 6import Graphics.Rendering.OpenGL.GL (($=))
7import Graphics.Rendering.OpenGL.GL qualified as GL 7import qualified Graphics.Rendering.OpenGL.GL as GL
8import Pong 8import Pong
9import Spear.App 9import Spear.App
10import Spear.Game 10import Spear.Game
11import Spear.Math.AABB 11import Spear.Math.AABB
12import Spear.Math.Spatial2 12import Spear.Math.Spatial2
13import Spear.Math.Vector 13import Spear.Math.Vector
14import Spear.Window 14import Spear.Window
15 15
16data GameState = GameState 16data GameState = GameState
17 { window :: Window, 17 { window :: Window,
18 world :: [GameObject] 18 world :: [GameObject]
19 } 19 }
20 20
21main = 21main =
@@ -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
72translate = mapMaybe translate' 72translate = mapMaybe translate'
73 73
74translate' (KeyDown KEY_LEFT) = Just MoveLeft 74translate' (KeyDown KEY_LEFT) = Just MoveLeft
75translate' (KeyDown KEY_RIGHT) = Just MoveRight 75translate' (KeyDown KEY_RIGHT) = Just MoveRight
76translate' (KeyUp KEY_LEFT) = Just StopLeft 76translate' (KeyUp KEY_LEFT) = Just StopLeft
77translate' (KeyUp KEY_RIGHT) = Just StopRight 77translate' (KeyUp KEY_RIGHT) = Just StopRight
78translate' _ = Nothing 78translate' _ = Nothing
79 79
80exitRequested = any (== (KeyDown KEY_ESC)) 80exitRequested = elem (KeyDown KEY_ESC)
81 81
82f2d :: Float -> GL.GLdouble 82f2d :: Float -> GL.GLdouble
83f2d = realToFrac 83f2d = realToFrac