summaryrefslogtreecommitdiffstats
path: root/src/Collision.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-03-16 02:34:31 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-03-16 02:34:31 +0100
commit98ae7f48c5c041cad0ffebe3793b0c74e8378512 (patch)
tree24d9dc4a52cc42c8eaf521daf194ebeb21e4acb0 /src/Collision.hs
parent90b8d87e02bfb0d1d3d10c3b824df8fd8ce37a9f (diff)
downloadhtanks-98ae7f48c5c041cad0ffebe3793b0c74e8378512.tar
htanks-98ae7f48c5c041cad0ffebe3793b0c74e8378512.zip
Added bullet/bullet collision
Diffstat (limited to 'src/Collision.hs')
-rw-r--r--src/Collision.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Collision.hs b/src/Collision.hs
index 84227d4..fad7cd6 100644
--- a/src/Collision.hs
+++ b/src/Collision.hs
@@ -1,7 +1,9 @@
module Collision ( collisionTankBorder
+ , collisionBulletBullet
) where
import Tank
+import Game
import Data.Fixed
import Data.Ratio
@@ -12,6 +14,9 @@ tankWidth = 0.95
tankLength :: Micro
tankLength = 0.95
+bulletDiameter :: Micro
+bulletDiameter = 0.2
+
collisionTankBorder :: Micro -> Micro -> Tank -> Tank
collisionTankBorder lw lh tank = tank {tankX = newx, tankY = newy}
where
@@ -39,3 +44,8 @@ collisionTankBorder lw lh tank = tank {tankX = newx, tankY = newy}
newx = (tankX tank) + dx
newy = (tankY tank) + dy
+
+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