summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-03-17 17:55:03 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-03-17 17:55:03 +0100
commita1294859c7512f3416612f0911946e7768d95bdd (patch)
treec4e6a7d40e4c627620c2bcba1caa0e8f32120df8 /src
parent98ae7f48c5c041cad0ffebe3793b0c74e8378512 (diff)
downloadhtanks-a1294859c7512f3416612f0911946e7768d95bdd.tar
htanks-a1294859c7512f3416612f0911946e7768d95bdd.zip
Some optimizations
Diffstat (limited to 'src')
-rw-r--r--src/Collision.hs4
-rw-r--r--src/HTanks.hs4
-rw-r--r--src/Render.hs24
3 files changed, 16 insertions, 16 deletions
diff --git a/src/Collision.hs b/src/Collision.hs
index fad7cd6..9ad898b 100644
--- a/src/Collision.hs
+++ b/src/Collision.hs
@@ -15,7 +15,7 @@ tankLength :: Micro
tankLength = 0.95
bulletDiameter :: Micro
-bulletDiameter = 0.2
+bulletDiameter = 0.1
collisionTankBorder :: Micro -> Micro -> Tank -> Tank
collisionTankBorder lw lh tank = tank {tankX = newx, tankY = newy}
@@ -48,4 +48,4 @@ collisionTankBorder lw lh tank = tank {tankX = newx, tankY = newy}
collisionBulletBullet :: (Bullet, Bullet) -> (Bullet, Bullet) -> Bool
collisionBulletBullet (b1, b1') (b2, b2') = distancesq < (bulletDiameter^2)
where
- distancesq = (bulletX b1' - bulletX b2')^2 + (bulletY b1' - bulletY b2')^2 \ No newline at end of file
+ distancesq = (bulletX b1' - bulletX b2')^2 + (bulletY b1' - bulletY b2')^2
diff --git a/src/HTanks.hs b/src/HTanks.hs
index c815992..15c3ed6 100644
--- a/src/HTanks.hs
+++ b/src/HTanks.hs
@@ -32,8 +32,8 @@ main = do
[ SomePlayer $ DefaultPlayer S.empty 0 0 False
, SomePlayer $ CPUPlayer 0
]}
- gameState = GameState {level = theLevel, tanks = [ Tank 5.0 5.0 0 0 2 270 False 3 2 5
- , Tank 5.0 3.5 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 1 5
], bullets = [], textures = M.empty}
runGame gameState $ do
diff --git a/src/Render.hs b/src/Render.hs
index e243580..a5f5ae9 100644
--- a/src/Render.hs
+++ b/src/Render.hs
@@ -19,8 +19,8 @@ import qualified Data.Map as M
import Bindings.GLPng
import Graphics.Rendering.OpenGL.GL (($=), GLfloat, GLdouble, Capability(..), Vector3(..))
-import Graphics.Rendering.OpenGL.GL.BeginEnd (renderPrimitive, PrimitiveMode(..))
-import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, preservingMatrix, ortho, translate, rotate)
+import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..))
+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.PerFragment (blend, blendFunc, BlendingFactor(..))
import Graphics.Rendering.OpenGL.GL.Texturing.Application (texture)
@@ -86,7 +86,7 @@ render = do
texture Texture2D $= Enabled
textureBinding Texture2D $= Just textureWood
- renderPrimitive Quads $ do
+ unsafeRenderPrimitive Quads $ do
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
vertex $ Vertex2 0 lh
@@ -99,7 +99,7 @@ render = do
texCoord $ TexCoord2 0 (lh/2)
vertex $ Vertex2 (0 :: GLfloat) (0 :: GLfloat)
- forM_ tanklist $ \tank -> preservingMatrix $ do
+ forM_ tanklist $ \tank -> unsafePreservingMatrix $ do
let x = fromReal . tankX $ tank
y = fromReal . tankY $ tank
rotDir = fromReal . tankDir $ tank
@@ -110,7 +110,7 @@ render = do
textureBinding Texture2D $= Just textureTank
- renderPrimitive Quads $ do
+ unsafeRenderPrimitive Quads $ do
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
vertex $ Vertex2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
@@ -127,7 +127,7 @@ render = do
textureBinding Texture2D $= Just textureCannon
- renderPrimitive Quads $ do
+ unsafeRenderPrimitive Quads $ do
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
vertex $ Vertex2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
@@ -140,7 +140,7 @@ render = do
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
vertex $ Vertex2 (0.5 :: GLfloat) (-0.5 :: GLfloat)
- forM_ bulletlist $ \bullet -> preservingMatrix $ do
+ forM_ bulletlist $ \bullet -> unsafePreservingMatrix $ do
let x = fromReal . bulletX $ bullet
y = fromReal . bulletY $ bullet
rotDir = fromReal . bulletDir $ bullet
@@ -150,18 +150,18 @@ render = do
textureBinding Texture2D $= Just textureBullet
- renderPrimitive Quads $ do
+ unsafeRenderPrimitive Quads $ do
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)
- vertex $ Vertex2 (-0.2 :: GLfloat) (0.2 :: GLfloat)
+ vertex $ Vertex2 (-0.1 :: GLfloat) (0.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)
- vertex $ Vertex2 (0.2 :: GLfloat) (-0.2 :: GLfloat)
+ vertex $ Vertex2 (0.1 :: GLfloat) (-0.1 :: GLfloat)
fromReal :: (Real a, Fractional b) => a -> b