SFML community forums
Help => Graphics => Topic started by: montez on January 12, 2016, 07:42:20 pm
-
Hi, I'm using sfml for a while in personal game projects, and I'm stuck with the intersection method from Rect<T>.
The rectangles :
sf::IntRect(sf::Vector2i(7, 7), sf::Vector2i(11, 11));
sf::IntRect(sf::Vector2i(10, 14), sf::Vector2i(16, 22));
for some reason they're intersecting each other. I may be wrong, but it shouldn't happen.
Thanks for your help!
-
They do in fact intersect:
The first box is positioned at: 7,7 with a size of 11,11
The second box ist positioned at: 10,14 with a size of 16,22
With this information you get:
(http://i.imgur.com/nQw6QMy.png)
If you use 2 vectors as function arguments the first one refers to the position and the second one refers to the size.
-
The second parameter is the size, not the other corner, so a rectangle that starts at (7,7) and has a size of 11x11, will intersect a rectangle which has a corner at (10,14).
Edit: Damn it, you beat me to it.
-
True... I was using "position/size" for the logical coordinates and "position/position" for drawing coordinates, so it was showing correctly, but logicaly it was wrong.
Thanks for poiting that out and sorry for the trouble.