summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Collision.hs2
-rw-r--r--src/Render.hs45
2 files changed, 33 insertions, 14 deletions
diff --git a/src/Collision.hs b/src/Collision.hs
index 30ec6e9..3138473 100644
--- a/src/Collision.hs
+++ b/src/Collision.hs
@@ -10,7 +10,7 @@ import Data.Fixed
import Data.Ratio
tankWidth :: Micro
-tankWidth = 0.95
+tankWidth = 0.4
tankLength :: Micro
tankLength = 0.95
diff --git a/src/Render.hs b/src/Render.hs
index bf3bb39..82ad08e 100644
--- a/src/Render.hs
+++ b/src/Render.hs
@@ -25,9 +25,10 @@ import Bindings.GLPng
import Graphics.Rendering.OpenGL.GL (($=), GLfloat, GLdouble, Capability(..), Vector3(..))
import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..))
-import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, unsafePreservingMatrix, ortho, translate, rotate, scale)
+import Graphics.Rendering.OpenGL.GL.CoordTrans
+import Graphics.Rendering.OpenGL.GL.Colors
import Graphics.Rendering.OpenGL.GL.Framebuffer (clear, ClearBuffer(..))
-import Graphics.Rendering.OpenGL.GL.PerFragment (blend, blendFunc, BlendingFactor(..))
+import Graphics.Rendering.OpenGL.GL.PerFragment (blend, blendFunc, BlendingFactor(..), depthFunc, ComparisonFunction(..))
import Graphics.Rendering.OpenGL.GL.Texturing.Application (texture)
import Graphics.Rendering.OpenGL.GL.Texturing.Objects (textureBinding, TextureObject(..))
import Graphics.Rendering.OpenGL.GL.Texturing.Parameters (Repetition(..), Clamping(..), TextureFilter(..), MinificationFilter, MagnificationFilter)
@@ -88,9 +89,29 @@ getModel m = do
setup :: Main ()
setup = do
+ (lw, lh) <- gets (level . gameState) >>= \l -> return (fromIntegral . levelWidth $ l :: GLfloat, fromIntegral . levelHeight $ l :: GLfloat)
+
liftIO $ do
- blend $= Enabled
- blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
+ matrixMode $= Projection
+ scale 1 1 (0.1 :: GLfloat)
+ translate $ Vector3 (lw/2) (lh/2) 0
+ rotate (-30) $ Vector3 1 0 (0 :: GLfloat)
+ translate $ Vector3 (-lw/2) (-lh/2) 0
+ matrixMode $= Modelview 0
+
+ blend $= Enabled
+ blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
+ depthFunc $= Just Lequal
+ shadeModel $= Smooth
+ lighting $= Enabled
+ light (Light 0) $= Enabled
+ position (Light 0) $= Vertex4 (-1) (-1) 1 (0 :: GLfloat)
+ colorMaterial $= Just (Front, AmbientAndDiffuse)
+
+ clientState VertexArray $= Enabled
+ clientState NormalArray $= Enabled
+ clientState TextureCoordArray $= Enabled
+
-- cache textures & models
getTexture TextureWood
@@ -121,11 +142,13 @@ render = do
(lw, lh) <- gets (level . gameState) >>= \l -> return (fromIntegral . levelWidth $ l :: GLfloat, fromIntegral . levelHeight $ l :: GLfloat)
liftIO $ do
- clear [ColorBuffer]
+ clear [ColorBuffer, DepthBuffer]
texture Texture2D $= Enabled
textureBinding Texture2D $= Just textureWood
+ normal $ Normal3 0 0 (1 :: GLfloat)
+
unsafeRenderPrimitive Quads $ do
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
vertex $ Vertex2 0 lh
@@ -141,9 +164,6 @@ render = do
texture Texture2D $= Disabled
- clientState VertexArray $= Enabled
- clientState NormalArray $= Enabled
- clientState TextureCoordArray $= Enabled
bindInterleavedArrays modelTank
forM_ tanklist $ \tank -> unsafePreservingMatrix $ do
@@ -153,7 +173,6 @@ render = do
rotAim = realToFrac . tankAim $ tank
translate $ Vector3 x y (0 :: GLfloat)
- scale 0.1 0.1 (0.1 :: GLfloat)
rotate rotDir $ Vector3 0 0 (1 :: GLfloat)
--textureBinding Texture2D $= Just textureTank
@@ -212,16 +231,16 @@ render = do
unsafeRenderPrimitive Quads $ do
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
- vertex $ Vertex2 (-0.1 :: GLfloat) (-0.1 :: GLfloat)
+ vertex $ Vertex3 (-0.1 :: GLfloat) (-0.1 :: GLfloat) 0.01
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat)
- vertex $ Vertex2 (-0.1 :: GLfloat) (0.1 :: GLfloat)
+ vertex $ Vertex3 (-0.1 :: GLfloat) (0.1 :: GLfloat) 0.01
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat)
- vertex $ Vertex2 (0.1 :: GLfloat) (0.1 :: GLfloat)
+ vertex $ Vertex3 (0.1 :: GLfloat) (0.1 :: GLfloat) 0.01
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
- vertex $ Vertex2 (0.1 :: GLfloat) (-0.1 :: GLfloat)
+ vertex $ Vertex3 (0.1 :: GLfloat) (-0.1 :: GLfloat) 0.01
textureBinding Texture2D $= Just textureCrosshair
forM_ playerlist renderPlayer