Some optimizations
This commit is contained in:
parent
98ae7f48c5
commit
a1294859c7
3 changed files with 16 additions and 16 deletions
|
@ -15,7 +15,7 @@ tankLength :: Micro
|
||||||
tankLength = 0.95
|
tankLength = 0.95
|
||||||
|
|
||||||
bulletDiameter :: Micro
|
bulletDiameter :: Micro
|
||||||
bulletDiameter = 0.2
|
bulletDiameter = 0.1
|
||||||
|
|
||||||
collisionTankBorder :: Micro -> Micro -> Tank -> Tank
|
collisionTankBorder :: Micro -> Micro -> Tank -> Tank
|
||||||
collisionTankBorder lw lh tank = tank {tankX = newx, tankY = newy}
|
collisionTankBorder lw lh tank = tank {tankX = newx, tankY = newy}
|
||||||
|
|
|
@ -32,8 +32,8 @@ main = do
|
||||||
[ SomePlayer $ DefaultPlayer S.empty 0 0 False
|
[ SomePlayer $ DefaultPlayer S.empty 0 0 False
|
||||||
, SomePlayer $ CPUPlayer 0
|
, SomePlayer $ CPUPlayer 0
|
||||||
]}
|
]}
|
||||||
gameState = GameState {level = theLevel, tanks = [ Tank 5.0 5.0 0 0 2 270 False 3 2 5
|
gameState = GameState {level = theLevel, tanks = [ Tank 5.0 5.0 0 0 2 270 False 3 1 5
|
||||||
, Tank 5.0 3.5 0 0 2 270 False 3 2 5
|
, Tank 5.0 3.5 0 0 2 270 False 3 1 5
|
||||||
], bullets = [], textures = M.empty}
|
], bullets = [], textures = M.empty}
|
||||||
|
|
||||||
runGame gameState $ do
|
runGame gameState $ do
|
||||||
|
|
|
@ -19,8 +19,8 @@ import qualified Data.Map as M
|
||||||
import Bindings.GLPng
|
import Bindings.GLPng
|
||||||
|
|
||||||
import Graphics.Rendering.OpenGL.GL (($=), GLfloat, GLdouble, Capability(..), Vector3(..))
|
import Graphics.Rendering.OpenGL.GL (($=), GLfloat, GLdouble, Capability(..), Vector3(..))
|
||||||
import Graphics.Rendering.OpenGL.GL.BeginEnd (renderPrimitive, PrimitiveMode(..))
|
import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..))
|
||||||
import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, preservingMatrix, ortho, translate, rotate)
|
import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, unsafePreservingMatrix, ortho, translate, rotate)
|
||||||
import Graphics.Rendering.OpenGL.GL.Framebuffer (clear, ClearBuffer(..))
|
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(..))
|
||||||
import Graphics.Rendering.OpenGL.GL.Texturing.Application (texture)
|
import Graphics.Rendering.OpenGL.GL.Texturing.Application (texture)
|
||||||
|
@ -86,7 +86,7 @@ render = do
|
||||||
texture Texture2D $= Enabled
|
texture Texture2D $= Enabled
|
||||||
textureBinding Texture2D $= Just textureWood
|
textureBinding Texture2D $= Just textureWood
|
||||||
|
|
||||||
renderPrimitive Quads $ do
|
unsafeRenderPrimitive Quads $ do
|
||||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||||
vertex $ Vertex2 0 lh
|
vertex $ Vertex2 0 lh
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ render = do
|
||||||
texCoord $ TexCoord2 0 (lh/2)
|
texCoord $ TexCoord2 0 (lh/2)
|
||||||
vertex $ Vertex2 (0 :: GLfloat) (0 :: GLfloat)
|
vertex $ Vertex2 (0 :: GLfloat) (0 :: GLfloat)
|
||||||
|
|
||||||
forM_ tanklist $ \tank -> preservingMatrix $ do
|
forM_ tanklist $ \tank -> unsafePreservingMatrix $ do
|
||||||
let x = fromReal . tankX $ tank
|
let x = fromReal . tankX $ tank
|
||||||
y = fromReal . tankY $ tank
|
y = fromReal . tankY $ tank
|
||||||
rotDir = fromReal . tankDir $ tank
|
rotDir = fromReal . tankDir $ tank
|
||||||
|
@ -110,7 +110,7 @@ render = do
|
||||||
|
|
||||||
textureBinding Texture2D $= Just textureTank
|
textureBinding Texture2D $= Just textureTank
|
||||||
|
|
||||||
renderPrimitive Quads $ do
|
unsafeRenderPrimitive Quads $ do
|
||||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||||
vertex $ Vertex2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
|
vertex $ Vertex2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ render = do
|
||||||
|
|
||||||
textureBinding Texture2D $= Just textureCannon
|
textureBinding Texture2D $= Just textureCannon
|
||||||
|
|
||||||
renderPrimitive Quads $ do
|
unsafeRenderPrimitive Quads $ do
|
||||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||||
vertex $ Vertex2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
|
vertex $ Vertex2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ render = do
|
||||||
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
|
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
|
||||||
vertex $ Vertex2 (0.5 :: GLfloat) (-0.5 :: GLfloat)
|
vertex $ Vertex2 (0.5 :: GLfloat) (-0.5 :: GLfloat)
|
||||||
|
|
||||||
forM_ bulletlist $ \bullet -> preservingMatrix $ do
|
forM_ bulletlist $ \bullet -> unsafePreservingMatrix $ do
|
||||||
let x = fromReal . bulletX $ bullet
|
let x = fromReal . bulletX $ bullet
|
||||||
y = fromReal . bulletY $ bullet
|
y = fromReal . bulletY $ bullet
|
||||||
rotDir = fromReal . bulletDir $ bullet
|
rotDir = fromReal . bulletDir $ bullet
|
||||||
|
@ -150,18 +150,18 @@ render = do
|
||||||
|
|
||||||
textureBinding Texture2D $= Just textureBullet
|
textureBinding Texture2D $= Just textureBullet
|
||||||
|
|
||||||
renderPrimitive Quads $ do
|
unsafeRenderPrimitive Quads $ do
|
||||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||||
vertex $ Vertex2 (-0.2 :: GLfloat) (-0.2 :: GLfloat)
|
vertex $ Vertex2 (-0.1 :: GLfloat) (-0.1 :: GLfloat)
|
||||||
|
|
||||||
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat)
|
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat)
|
||||||
vertex $ Vertex2 (-0.2 :: GLfloat) (0.2 :: GLfloat)
|
vertex $ Vertex2 (-0.1 :: GLfloat) (0.1 :: GLfloat)
|
||||||
|
|
||||||
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat)
|
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat)
|
||||||
vertex $ Vertex2 (0.2 :: GLfloat) (0.2 :: GLfloat)
|
vertex $ Vertex2 (0.1 :: GLfloat) (0.1 :: GLfloat)
|
||||||
|
|
||||||
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
|
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
|
||||||
vertex $ Vertex2 (0.2 :: GLfloat) (-0.2 :: GLfloat)
|
vertex $ Vertex2 (0.1 :: GLfloat) (-0.1 :: GLfloat)
|
||||||
|
|
||||||
|
|
||||||
fromReal :: (Real a, Fractional b) => a -> b
|
fromReal :: (Real a, Fractional b) => a -> b
|
||||||
|
|
Reference in a new issue