self.collision = function () {
if(collisions(tank.x, enemyTank.x, tank.y, enemyTank.y, tank.width, tank.height, enemyTank,width, enemyTank,height)) {
console.log("detected");
}
}
function collisions(rect1, rect2) {
var rect1 = {x: tank.x, y: tank.y, width: tank.width, height: tank.height}
var rect2 = {x: enemyTank.x, y: enemyTank.y, width: enemyTank.width, height: enemyTank.height}
return (rect1.x < rect2.x + rect2.width &&
rect1.x + rect1.width > rect2.x &&
rect1.y < rect2.y + rect2.height &&
rect1.y + rect1.height > rect2.y)
}