#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <string>
using namespace std;
class Dot
{
private:
sf::CircleShape dot;
sf::Mouse mouse;
sf::Vector2f position;
public:
sf::CircleShape drawDot()
{
position = static_cast<sf::Vector2f>(mouse.getPosition());
dot.setRadius(150);
dot.setFillColor(sf::Color::Green);
dot.setPosition(position);
return dot;
}
};
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "Snake");
sf::Event event;
sf:: Time time = sf::seconds(5);
Dot dots;
while(window.isOpen() == true)
{
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
{
window.close();
}
if(event.type == sf::Event::KeyPressed)
{
sf::CircleShape gm;
gm = dots.drawDot();
window.draw(gm);
}
window.clear(sf::Color::Black);
window.display();
}
}
}
When debugging it completly skips the keyboard if statement.