Added bullet/bullet collision
This commit is contained in:
parent
90b8d87e02
commit
98ae7f48c5
2 changed files with 25 additions and 5 deletions
|
@ -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
|
Reference in a new issue