Here is my code. I'm trying to make a simple Paint program.
sf::RenderWindow Paint(sf::VideoMode(800, 600), "Paint");
sf::String GetString()
{
sf::Input mouseInput;
std::stringstream out;
out << "x: " << Paint.GetInput().GetMouseX() << "\ny: " << Paint.GetInput().GetMouseY();
std::string myString;
myString = out.str();
sf::Unicode::Text myText(myString);
sf::String thisString(myText, sf::Font::GetDefaultFont(), 15);
return thisString;
}
class DrawingSpace
{
public:
sf::Shape Rect1;
DrawingSpace(sf::RenderWindow* Paint)
{
// the color panel
sf::Shape Panel = sf::Shape::Rectangle(0, 0, 100, 600, sf::Color(100, 100, 100));
Paint->Draw(Panel);
// the white color
Rect1 = sf::Shape::Rectangle(10, 100, 90, 190, sf::Color(0, 0, 0));
Paint->Draw(Rect1);
// the drawing space
sf::Shape space = sf::Shape::Rectangle(100, 0, 800, 600, sf::Color(0, 0, 0));
Paint->Draw(space);
}
};
int main()
{
DrawingSpace* Space = new DrawingSpace(&Paint);
while (Paint.IsOpened())
{
sf::Event myEvent;
while (Paint.GetEvent(myEvent))
{
if (myEvent.Type == sf::Event::MouseMoved)
{
Paint.Clear();
delete Space;
Space = new DrawingSpace(&Paint);
Paint.Draw(GetString());
}
if (myEvent.Type == sf::Event::Closed)
Paint.Close();
}
Paint.Display();
}
return 0;
}