diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2010-02-23 23:31:11 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2010-02-23 23:31:11 +0100 |
commit | 9036ac310501dd9d2eba181270711c328963d17f (patch) | |
tree | 9092fa694377179b014abe7b3c006363f8408bdf /Render.hs | |
parent | 366eb711dd05a7ad446f48d57f0645d89813ade4 (diff) | |
download | htanks-9036ac310501dd9d2eba181270711c328963d17f.tar htanks-9036ac310501dd9d2eba181270711c328963d17f.zip |
Use state monad to hold main loop state
Diffstat (limited to 'Render.hs')
-rw-r--r-- | Render.hs | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -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) |