sf::RenderWindow window;
window.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Test");
sf::Vector2i mouseOffsetOrigin = sf::Vector2i(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
sf::Vector2f mouseOffset(std::ceil(sf::Mouse::getPosition(window).x - mouseOffsetOrigin.x), std::ceil(sf::Mouse::getPosition(window).y - mouseOffsetOrigin.y));
sf::Texture texture;
texture.loadFromFile("example.png");
sf::Sprite sprite(texture);
while(true){
sprite.move(mouseOffset.x, mouseOffset.y);
sf::Mouse::setPosition(mouseOffsetOrigin, window);
window.clear();
window.draw(sprite);
}
I didn't test, but that should? compile in a main() function. Anyways, to reiterate, the sprite seems rather unresponsive. The sprite moves now at least (line 3 of my code was setting the origin to the mouse's current position, I fixed that to the screen's center), but the sprite seems to drift and is oversensitive. I know the problem has now gone from "bug with sf::Event" to "help me move my sprite smoothly" but it's still annoying to me. How can I move the sprite smoothly with the mouse opposed to its current jerkiness?
Edit: I just thought of a great metaphor to explain this "jerkiness." When I move my cursor onscreen outside my application, it stays in a pretty straight, coherent line. When I move my sprite in the program's window, the sprite looks like a really drunk version of the cursor that can't even walk a straight line