diff options
Diffstat (limited to 'src/DefaultPlayer.hs')
-rw-r--r-- | src/DefaultPlayer.hs | 22 |
1 files changed, 22 insertions, 0 deletions
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) |