1
Window / Shape following cursor at a certain speed
« on: October 08, 2021, 04:41:15 pm »
So, we're trying to make a CircleShape follow the mouse's position at a speed of 500 pixels per second. We're like super noobs to SFML (like just started learning last week after learning C++ the week before).
We know the code for the circle following the mouse is...
But we don't know how to get the circle to follow the mouse slowly. We tried cursor.move and even did some trigo sh** but we don't understand it enough to make sense of it. If someone could help, that would be great!
We know the code for the circle following the mouse is...
//while window is open blah blah we have other code here so we only posted the relevant code
sf::CircleShape cursor;
cursor.setRadius(10.0f);
cursor.setFillColor(sf::Color::Yellow);
cursor.setPosition(WINDOW_W, WINDOW_H);
while (window.pollEvent(event)) {
sf::Vector2f mousePos = sf::Vector2f(window.mapPixelToCoords(sf::Mouse::getPosition(window)));
cursor.setPosition(mousePos);
}
sf::CircleShape cursor;
cursor.setRadius(10.0f);
cursor.setFillColor(sf::Color::Yellow);
cursor.setPosition(WINDOW_W, WINDOW_H);
while (window.pollEvent(event)) {
sf::Vector2f mousePos = sf::Vector2f(window.mapPixelToCoords(sf::Mouse::getPosition(window)));
cursor.setPosition(mousePos);
}
But we don't know how to get the circle to follow the mouse slowly. We tried cursor.move and even did some trigo sh** but we don't understand it enough to make sense of it. If someone could help, that would be great!