First off, I would make a function to check if a given coordinate is within a given bounding box; pointInRectangle is what I usually call it. That function would look like
inline int clamp(int val, int min, int max) {
val = val < min ? min : val;
val = val > max ? max : val;
return val
}
inline bool pointInRectangle(int x, int y, int x1, int y1, int x2, int y2) {
return (clamp(x, x1, x2) == x && clamp(y, y1, y2) == y);
(You need clamp to make pointInRectangle even easier to read)
With that function, you could just say
int x sf::Mouse::getPosition().x;
int y sf::Mouse::getPosition().y;
int x1 = sprite.getPosition().x;
int y1 = sprite.getPosition().y;
int x2 = sprite.getPosition().x + (sprite.getScale().x * 275);
int y2 = sprite.getPosition().y + (sprite.getScale().y * 275);
if (pointInRectangle(x, y, x1, y1, x2, y2) && sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
// Do stuff...
}
Of course you could remove all the variables I set there, I just hate looking at that much within parameters.