I am working on a mobile game in c++ in Replit, and have run into an issue.
I have a rectangle, defined with a color, position, and specific origin. I rotate it every frame, but it rotates around 0, 0 instead of it's origin. I have looked through similar problems but none solve my problem.
Here is my code
int main()
{
RenderWindow window(VideoMode(375, 475), "");
RectangleShape sprite(Vector2f(275, 25));
Vector2f Position(-187.5f, -375);
sprite.setOrigin(Position);
sprite.setFillColor(Color::White);
sprite.setPosition(-137.5, 0);
while (window.isOpen()) {
Event event;
while (window.pollEvent(event)) {
if (event.type == Event::Closed)
window.close();
}
window.clear();
window.draw(sprite);
sprite.rotate(0.01);
// Copy the buffer to the window.
window.display();
}
return 0;
}
Here is a screenshot of the code running:
Can anyone help me?