summaryrefslogtreecommitdiffstats
path: root/Render.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-02-23 23:31:11 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-02-23 23:31:11 +0100
commit9036ac310501dd9d2eba181270711c328963d17f (patch)
tree9092fa694377179b014abe7b3c006363f8408bdf /Render.hs
parent366eb711dd05a7ad446f48d57f0645d89813ade4 (diff)
downloadhtanks-9036ac310501dd9d2eba181270711c328963d17f.tar
htanks-9036ac310501dd9d2eba181270711c328963d17f.zip
Use state monad to hold main loop state
Diffstat (limited to 'Render.hs')
-rw-r--r--Render.hs20
1 files changed, 13 insertions, 7 deletions
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)