From 9036ac310501dd9d2eba181270711c328963d17f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 23 Feb 2010 23:31:11 +0100 Subject: Use state monad to hold main loop state --- Render.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'Render.hs') diff --git a/Render.hs b/Render.hs index 86a7ccf..b11e2ff 100644 --- a/Render.hs +++ b/Render.hs @@ -5,6 +5,7 @@ module Render ( setup import Game +import Tank import Control.Monad.State @@ -16,8 +17,9 @@ import Graphics.Rendering.OpenGL.GL.VertexSpec setup :: Int -> Int -> IO () -setup = resize - +setup w h = do + resize w h + resize :: Int -> Int -> IO () resize w h = do let wn = fromIntegral w @@ -34,11 +36,15 @@ resize w h = do render :: Game () -render = liftIO $ do +render = do + tank <- liftM head $ gets tanks + let x = posx tank + y = posy tank + + liftIO $ do clear [ColorBuffer] renderPrimitive Triangles $ do - vertex $ Vertex2 (-0.5 :: GLfloat) (0.5 :: GLfloat) - vertex $ Vertex2 (0.5 :: GLfloat) (0.5 :: GLfloat) - vertex $ Vertex2 (0.5 :: GLfloat) (-0.5 :: GLfloat) - \ No newline at end of file + vertex $ Vertex2 (x-0.5 :: GLfloat) (y+0.5 :: GLfloat) + vertex $ Vertex2 (x+0.5 :: GLfloat) (y+0.5 :: GLfloat) + vertex $ Vertex2 (x+0.5 :: GLfloat) (y-0.5 :: GLfloat) -- cgit v1.2.3