Hello there.
I just have a little problem I can't wrap my head around.
The function "intersects" returns true even if the rects should not have space in common.
#include "stdafx.h"
#include "SFML\Graphics.hpp"
int _tmain(int argc, _TCHAR* argv[])
{
sf::Rect<float> rect1 (4.0f, 3.0f, 4.5f, 3.5f); // Hint: Nexus = sf::Rect<float> (4.0f, 3.0f, 4.5f, 3.5f);
sf::Rect<float> rect2 (4.0f, 3.5f, 4.5f, 4.0f); // Hint: Nexus = sf::Rect<float> (4.0f, 3.5f, 4.5f, 4.0f);
sf::Rect<float> rect3 (6.0f, 7.0f, 7.0f, 8.0f); // Hint: Nexus = sf::Rect<float> (6.0f, 7.0f, 7.0f, 8.0f);
if (rect1.intersects (rect3)) std::cout << "Rect 1 intersects Rect 3" << std::endl;
if (rect2.intersects (rect3)) std::cout << "Rect 2 intersects Rect 3" << std::endl;
system("PAUSE");
return 0;
}
On my console the program returns: Rect 2 intersects Rect 3.
From what I understand it should look like that:
(Rect 1 isn't shown)
So, where am I wrong, or why do they intersect?
Thanks in advance.