Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - xRiccardoC++

Pages: [1]
1
Graphics / I'm having problems with drawing
« on: September 24, 2018, 02:51:01 pm »
I'm trying to use a sf::CircleShape as a brush because i want to make a paint remake or something like that. Because of that i don't clear the window every frame and this causes a really weird thing to happen.

#include <SFML/Graphics.hpp>

int main()
{
    using namespace sf;
    RenderWindow window(VideoMode(800, 600), "Title_String");
    window.setFramerateLimit(60);

    CircleShape brush(16.0f);
    brush.setFillColor(Color::Red);

    window.clear(Color::Black);

    while (window.isOpen())
    {
        Event e;
        while (window.pollEvent(e))
        {
            if (e.type == Event::Closed)
            {
                window.close();
            }
        }

        if (Mouse::isButtonPressed(Mouse::Button::Left))
        {
            int mx = Mouse::getPosition(window).x;
            int my = Mouse::getPosition(window).y;
            brush.setPosition(mx - 8, my - 8);
            window.draw(brush);
        }

        window.display();
    }


    return 0;
}

Pages: [1]
anything