I have a very simple code and would like to know how can I when I click with the mouse on the screen and draw a point when clicking a second time, a second point to draw a line connecting one point to another?
My code so far is this:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <math.h>
#define PI 3.1416
#include "Vector2D.h"
using namespace std;
int main(){
// Inicializacao da biblioteca
sf::RenderWindow* app = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "Exercicio 2");
Vector2D vetor(3,4);
Vector2D va(3,4);
Vector2D vb(4,5);
va+=vb;
// Gameloop - Le os eventos
while (app->IsOpened()) {
//Leitura dos eventos
sf::Event* event = new sf::Event();
while (app->GetEvent(*event)) {
if (event->Type == sf::Event::Closed) {
app->Close();
}
}
if (app->GetInput().IsKeyDown(sf::Key::Escape)) {//se apertar ESC o jogo fecha
return EXIT_SUCCESS;
}
app->Clear(sf::Color(255, 255, 255));
sf::Shape Circle = sf::Shape::Circle(200, 200, 5, sf::Color(125, 200, 240), 1, sf::Color(0, 0, 0));
app->Draw(Circle);
app->Display();
}
return EXIT_SUCCESS;
}