I am creating a tower defense game, I create the tower and the enemy and I want the tower to shoot at the enemy, I am rotating the bullet to face the enemy based on the position of the tower using this code right after creating the bullet
Bullets Temp;
Temp.SetX(TowerVector[a].GetX());
Temp.SetY(TowerVector[a].GetY());
BulletVector.push_back(Temp);
sf::Vector2f curPos = TowerVector[a].Sprite.GetPosition();
sf::Vector2f position =EnemyVector[b].Sprite.GetPosition();
const float PI = 3.14159265;
float dx = curPos.x - position.x;
float dy = curPos.y - position.y;
float rotation = (atan2(dy, dx)) * 180 / PI + 180;
BulletVector[BulletVector.size()].Sprite.SetRotation(rotation);
Its causes my game to break when it should shoot, is there anything wrong with the rotation code or is it something else?