I'm planning on adding a text-highlighting feature to my little project, (I wrote one before, but it was spaghetti code and very buggy)
I started with
case sf::Event::MouseButtonReleased:
{
if(sf::Mouse::getPosition(MaWind).y != Mcoords[1]||sf::Mouse::getPosition(MaWind).x != Mcoords[0])
{
//Mcoords[0] is the x pos stored from the mouse button being clicked and you get it for Mcoords[1]
}
}
but then I realized having to check an if-statement every time the mouse button seems rather inefficient, is there a way i should be doing it other than this or this is the best possible?
i don't know if I understand what you are trying to do
but you could use a sf::vector2f instead. and the way you're doing its not inefficient at all, its simply conditionals
sf::vector2f mcoords(10, 20); //you can acces individual values with mcoords.x or mcoords.y
if (mcoords != sf::Mouse::getPosition(MaWind){
//code
}