// create a rectangle sf::IntRect rect(10, 10, 100, 100); // check if (50, 50) lies within the rectangle if (rect.contains(sf::Vector2i(50, 50))) { std::cout << "Point lies within the rectangle\n"; }
// create a rectangle sf::IntRect rect(10, 10, 100, 100); // check if (150, 150) lies within the rectangle if (rect.contains(sf::Vector2i(150, 150))) { std::cout << "Point lies within the rectangle\n"; } else { std::cout << "Point lies outside the rectangle\n"; }In this example, we create the same rectangle `rect` as before. This time, we check whether the point `(150, 150)` lies within the rectangle using the `contains` function. Since this point lies outside the rectangle, the output will be "Point lies outside the rectangle". Overall, `IntRect contains` is a useful function for checking whether a given point lies within a rectangle. It is a part of the SFML Graphics package library.