2
« on: December 11, 2016, 09:26:23 am »
Damn, its works, but it doing +1 line, i dont know why. CODE:
#include <SFML/Graphics.hpp>
#include <iostream>
#include <windows.h>
using namespace std;
using namespace sf;
int main()
{
RenderWindow window(sf::VideoMode(500, 500), "LINES");
int x,y;
vector<sf::Vertex> vertices;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::MouseButtonPressed)
{
if (event.mouseButton.button == sf::Mouse::Left)
{
x = Mouse::getPosition().x - 394; // Its doing mouse position for window
y = Mouse::getPosition().y - 259; // Its doing mouse position for window
vertices.push_back(sf::Vertex(Vector2f(x,y)));
}
}
}
window.clear();
if(vertices.size() != 0)
{for(int i = 0;i < vertices.size();++i){window.draw(&vertices,vertices.size(),LinesStrip);}}
window.display();
}
return 0;
}