diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2010-04-16 03:08:48 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2010-04-16 03:08:48 +0200 |
commit | a19dc0d6aa982d138f46305cdea6443cb45a5fd3 (patch) | |
tree | eb846615b4d22e2f1e76272b1460cc879f52f937 /src/Render.hs | |
parent | 5951108c0a47fed6d78e442ae4233d9d34eafe13 (diff) | |
download | htanks-a19dc0d6aa982d138f46305cdea6443cb45a5fd3.tar htanks-a19dc0d6aa982d138f46305cdea6443cb45a5fd3.zip |
Added more models and render with perspective transform now
Diffstat (limited to 'src/Render.hs')
-rw-r--r-- | src/Render.hs | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/src/Render.hs b/src/Render.hs index 91146ba..aa084d8 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -80,7 +80,7 @@ setup = do shadeModel $= Smooth lighting $= Enabled light (Light 0) $= Enabled - position (Light 0) $= Vertex4 (-1) (-1) 1 (0 :: GLfloat) + position (Light 0) $= Vertex4 (-1) (-1) 1.5 (0 :: GLfloat) colorMaterial $= Just (Front, AmbientAndDiffuse) clientState VertexArray $= Enabled @@ -96,6 +96,8 @@ setup = do getTexture TextureCrosshair getModel ModelTank + getModel ModelBullet + getModel ModelBlock return () @@ -113,6 +115,8 @@ render = do textureCrosshair <- getTexture TextureCrosshair modelTank <- getModel ModelTank + modelBullet <- getModel ModelBullet + modelBlock <- getModel ModelBlock (lw, lh) <- gets (level . gameState) >>= \l -> return (fromIntegral . levelWidth $ l :: GLfloat, fromIntegral . levelHeight $ l :: GLfloat) @@ -127,17 +131,17 @@ render = do normal $ Normal3 0 0 (1 :: GLfloat) unsafeRenderPrimitive Quads $ do - texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat) - vertex $ Vertex2 0 lh + texCoord $ TexCoord2 (-0.5 :: GLfloat) (-0.5 :: GLfloat) + vertex $ Vertex2 (-1) (lh+1) - texCoord $ TexCoord2 (lw/2) 0 - vertex $ Vertex2 lw lh + texCoord $ TexCoord2 (lw/2+0.5) (-0.5) + vertex $ Vertex2 (lw+1) (lh+1) - texCoord $ TexCoord2 (lw/2) (lh/2) - vertex $ Vertex2 lw 0 + texCoord $ TexCoord2 (lw/2+0.5) (lh/2+0.5) + vertex $ Vertex2 (lw+1) (-1) - texCoord $ TexCoord2 0 (lh/2) - vertex $ Vertex2 (0 :: GLfloat) (0 :: GLfloat) + texCoord $ TexCoord2 (-0.5) (lh/2+0.5) + vertex $ Vertex2 (-1 :: GLfloat) (-1 :: GLfloat) bindInterleavedArrays modelTank @@ -163,30 +167,44 @@ render = do unsafePreservingMatrix $ do rotate 90 $ Vector3 1 0 (0 :: GLfloat) drawObject modelTank 0 + + texture Texture2D $= Disabled + bindInterleavedArrays modelBullet forM_ bulletlist $ \bullet -> unsafePreservingMatrix $ do - let x = realToFrac . bulletX $ bullet - y = realToFrac . bulletY $ bullet - rotDir = realToFrac . bulletDir $ bullet - - translate $ Vector3 x y (0.2 :: GLfloat) - rotate 30 $ Vector3 1 0 (0 :: GLfloat) - rotate rotDir $ Vector3 0 0 (1 :: GLfloat) + let x = realToFrac . bulletX $ bullet + y = realToFrac . bulletY $ bullet + rotDir = realToFrac . bulletDir $ bullet - textureBinding Texture2D $= Just textureBullet + translate $ Vector3 x y (0.25 :: GLfloat) + rotate (rotDir-90) $ Vector3 0 0 (1 :: GLfloat) - unsafeRenderPrimitive Quads $ do - texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat) - vertex $ Vertex3 (-0.1 :: GLfloat) (-0.1 :: GLfloat) 0 - - texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat) - vertex $ Vertex3 (-0.1 :: GLfloat) (0.1 :: GLfloat) 0 - - texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat) - vertex $ Vertex3 (0.1 :: GLfloat) (0.1 :: GLfloat) 0 - - texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat) - vertex $ Vertex3 (0.1 :: GLfloat) (-0.1 :: GLfloat) 0 + unsafePreservingMatrix $ do + drawObject modelBullet 0 + + bindInterleavedArrays modelBlock + + texture Texture2D $= Enabled + textureBinding Texture2D $= Just textureWood + forM_ [0.5..13.5] $ \x -> unsafePreservingMatrix $ do + translate $ Vector3 x 8.5 (0.5 :: GLfloat) + rotate 90 $ Vector3 1 0 (0 :: GLfloat) + drawObject modelBlock 0 + + forM_ [0.5..13.5] $ \x -> unsafePreservingMatrix $ do + translate $ Vector3 x (-0.5) (0.5 :: GLfloat) + rotate 90 $ Vector3 1 0 (0 :: GLfloat) + drawObject modelBlock 0 + + forM_ [-0.5..8.5] $ \y -> unsafePreservingMatrix $ do + translate $ Vector3 (-0.5) y (0.5 :: GLfloat) + rotate 90 $ Vector3 1 0 (0 :: GLfloat) + drawObject modelBlock 0 + + forM_ [-0.5..8.5] $ \y -> unsafePreservingMatrix $ do + translate $ Vector3 14.5 y (0.5 :: GLfloat) + rotate 90 $ Vector3 1 0 (0 :: GLfloat) + drawObject modelBlock 0 depthFunc $= Just Always |