Hey,
I want to make the object rotation so it's relative to the mouse position.
In constructor I set the origin to the centre of the object and set its position:
Player::Player() {
setOrigin(width / 2, height / 2);
pos.x = 600.f;
pos.y = 300.f;
}
then I calculate the angle:
float Player::getAngle(sf::RenderWindow& window) {
x = sf::Mouse::getPosition(window).x - (pos.x + width / 2);
y = sf::Mouse::getPosition(window).y - (pos.y + height / 2);
angle = std::atan2(y, x) * 180 / M_PI;
printf("%f\n", angle);
return angle;
}
and draw it. However the origin seems to be very off because it rotates around a different point.
What am I missing?