summaryrefslogtreecommitdiffstats
path: root/Render.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-02-24 02:42:10 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-02-24 02:42:10 +0100
commit4a6d841bc7e3b17bf399ae2e39d409fe85a6fffb (patch)
tree2668cbf6f6c21f2ab5c44e7322e4237d29d34a1b /Render.hs
parent9036ac310501dd9d2eba181270711c328963d17f (diff)
downloadhtanks-4a6d841bc7e3b17bf399ae2e39d409fe85a6fffb.tar
htanks-4a6d841bc7e3b17bf399ae2e39d409fe85a6fffb.zip
Used fixed point numbers for coordinates
Diffstat (limited to 'Render.hs')
-rw-r--r--Render.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Render.hs b/Render.hs
index b11e2ff..ec34e78 100644
--- a/Render.hs
+++ b/Render.hs
@@ -9,6 +9,9 @@ import Tank
import Control.Monad.State
+import Data.Fixed
+import Data.Ratio
+
import Graphics.Rendering.OpenGL.GL (($=), GLfloat)
import Graphics.Rendering.OpenGL.GL.BeginEnd (renderPrimitive, PrimitiveMode(..))
import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, ortho)
@@ -38,13 +41,16 @@ resize w h = do
render :: Game ()
render = do
tank <- liftM head $ gets tanks
- let x = posx tank
- y = posy tank
+ let x = toFloat . posx $ tank
+ y = toFloat . posy $ tank
liftIO $ do
clear [ColorBuffer]
renderPrimitive Triangles $ do
- 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)
vertex $ Vertex2 (x+0.5 :: GLfloat) (y-0.5 :: GLfloat)
+
+toFloat :: Real a => a -> GLfloat
+toFloat = fromRational . toRational \ No newline at end of file