From 08762ddc9ac9be5a4a63b1d15b3955ceb27f76b2 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 12 Apr 2010 16:17:41 +0200 Subject: Simplified texture and model loading; also use crosshair for DefaultPlayer --- src/DefaultPlayer.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/DefaultPlayer.hs') diff --git a/src/DefaultPlayer.hs b/src/DefaultPlayer.hs index 756ba88..7f97f39 100644 --- a/src/DefaultPlayer.hs +++ b/src/DefaultPlayer.hs @@ -8,12 +8,17 @@ import qualified Data.Set as S import Data.Fixed import Data.Ratio ((%)) import Data.Typeable +import Graphics.Rendering.OpenGL.GL (GLfloat, Vector3(..)) +import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..)) +import Graphics.Rendering.OpenGL.GL.CoordTrans (unsafePreservingMatrix, translate, rotate) +import Graphics.Rendering.OpenGL.GL.VertexSpec import Tank import GLDriver import Player + data DefaultPlayer = DefaultPlayer (S.Set Key) Float Float Bool deriving (Typeable, Show) @@ -34,3 +39,20 @@ instance Player DefaultPlayer where | Just (MouseMotionEvent x y) <- fromEvent ev = DefaultPlayer keys x y shoot | Just (MousePressEvent x y) <- fromEvent ev = DefaultPlayer keys x y True | otherwise = DefaultPlayer keys aimx aimy shoot + + renderPlayer (DefaultPlayer _ aimx aimy _) = unsafePreservingMatrix $ do + translate $ Vector3 aimx aimy (0.2 :: GLfloat) + rotate 30 $ Vector3 1 0 (0 :: GLfloat) + + unsafeRenderPrimitive Quads $ do + texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat) + vertex $ Vertex2 (-0.2 :: GLfloat) (-0.2 :: GLfloat) + + texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat) + vertex $ Vertex2 (-0.2 :: GLfloat) (0.2 :: GLfloat) + + texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat) + vertex $ Vertex2 (0.2 :: GLfloat) (0.2 :: GLfloat) + + texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat) + vertex $ Vertex2 (0.2 :: GLfloat) (-0.2 :: GLfloat) -- cgit v1.2.3