void Enemy::EnemyDetectPlayer(sf::Vector2f playerPos, sf::Vector2f enemyPos){
float distance = (abs(sqrt(((playerPos.x - enemyPos.x) * (playerPos.x - enemyPos.x)) + ((playerPos.y - enemyPos.y) * (playerPos.y - enemyPos.y)))));
if (distance < 200 && m_gunIsOut == true){
//do something here
}
}
So I currently have the distance between enemy and player, but the problem is, wherever the enemy is eg (500,50) this distance < 200 wont work correctly because the enemies x+y isn't 0, it would be 500,50.
So my question is, how would I get the distance all around the enemy correctly so when the player is in distance, something will happen?