So i am trying to draw a consistent free line with circles along(sf::CircleShape). It works if I move the mouse slowly, but the circles get big gaps if i move it quickly. I was wondering if it possible to resolve this?
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(1920, 1080), "Test");
sf::Event event;
std::vector<sf::CircleShape> circles;
sf::Vector2f mouseCoords = window.mapPixelToCoords(sf::Vector2i(sf::Mouse::getPosition(window)));
while(window.isOpen())
{
mouseCoords = window.mapPixelToCoords(sf::Vector2i(sf::Mouse::getPosition(window)));
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
{
window.close();
}
if(event.type == sf::Event::MouseMoved)
{
sf::CircleShape newCircle;
newCircle.setPosition(mouseCoords);
newCircle.setRadius(3);
newCircle.setFillColor(sf::Color::Black);
circles.push_back(newCircle);
}
}
window.clear(sf::Color::White);
for(auto i : circles)
{
window.draw(i);
}
window.display();
}
}