#includeint main() { sf::RenderWindow window(sf::VideoMode(200, 200), "SFML Rectangle"); sf::FloatRect rect(50, 50, 100, 100); // create a rectangle float width = rect.width; // get the width of the rectangle std::cout << "Width of the rectangle: " << width << std::endl; while (window.isOpen()) { window.clear(); window.draw(sf::RectangleShape(sf::Vector2f(rect.width, rect.height))); window.display(); } return 0; }
#includeThis example compares the widths of two rectangles using the FloatRect width property.int main() { sf::FloatRect rect1(50, 50, 100, 100); sf::FloatRect rect2(25, 25, 75, 75); if (rect1.width > rect2.width) { std::cout << "Rectangle 1 is wider!" << std::endl; } else { std::cout << "Rectangle 2 is wider!" << std::endl; } return 0; }