Some improvements on coordinate calculation & player rendering

This commit is contained in:
Matthias Schiffer 2010-04-12 14:40:31 +02:00
parent d56001cb33
commit dafe16f191
4 changed files with 23 additions and 21 deletions

View file

@ -92,13 +92,6 @@ setup = do
(lw, lh) <- gets (level . gameState) >>= \l -> return (fromIntegral . levelWidth $ l :: GLfloat, fromIntegral . levelHeight $ l :: GLfloat)
liftIO $ do
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
@ -144,6 +137,8 @@ render = do
liftIO $ do
clear [ColorBuffer, DepthBuffer]
depthFunc $= Just Lequal
texture Texture2D $= Enabled
textureBinding Texture2D $= Just textureWood
@ -224,23 +219,26 @@ render = do
y = realToFrac . bulletY $ bullet
rotDir = realToFrac . bulletDir $ bullet
translate $ Vector3 x y (0 :: GLfloat)
translate $ Vector3 x y (0.1 :: GLfloat)
rotate 30 $ Vector3 1 0 (0 :: GLfloat)
rotate rotDir $ Vector3 0 0 (1 :: GLfloat)
textureBinding Texture2D $= Just textureBullet
unsafeRenderPrimitive Quads $ do
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
vertex $ Vertex3 (-0.1 :: GLfloat) (-0.1 :: GLfloat) 0.01
vertex $ Vertex3 (-0.1 :: GLfloat) (-0.1 :: GLfloat) 0
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat)
vertex $ Vertex3 (-0.1 :: GLfloat) (0.1 :: GLfloat) 0.01
vertex $ Vertex3 (-0.1 :: GLfloat) (0.1 :: GLfloat) 0
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat)
vertex $ Vertex3 (0.1 :: GLfloat) (0.1 :: GLfloat) 0.01
vertex $ Vertex3 (0.1 :: GLfloat) (0.1 :: GLfloat) 0
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
vertex $ Vertex3 (0.1 :: GLfloat) (-0.1 :: GLfloat) 0.01
vertex $ Vertex3 (0.1 :: GLfloat) (-0.1 :: GLfloat) 0
depthFunc $= Just Always
textureBinding Texture2D $= Just textureCrosshair
forM_ playerlist renderPlayer