SFML community forums
Help => Graphics => Topic started by: Haikarainen on April 23, 2011, 10:16:47 pm
-
To begin with, sry if ive been posting a lot of threads here in a very short period of time, my head is just a mess atm :P cant think. I also have a little project coming up in a few days (tonight/tomorrow if youre lucky!) that will eliminate all dirty megaupload links on these forums ;)
To the point:
I'm working on a collision detection system, that checks a characters collisionrectangle to a pixel perfect image tile .
So say we have:
sf::Rect Body.CollisionBox;
sf::Image Tile; // using position and size as "rect"
Ive came so far to check IF theyre intersecting, but now i need a third sf::Rect from WHERE the 2 other "rects" are intersecting.
I need the third rect to begin checking pixels(have no problem with how to do that), so i need the intersecting rect -> rect on the imagepixels.
Please help me, as i wrote before my head have been a mess the past 2 days, been working on this function tooo long now :P
-
If you use SFML 2, the member function sf::Rect::Intersects() (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Rect.htm#a10cfed83bc990d39a5fb3d319b86c1d8) can help you finding the intersection.
Otherwise, this shouldn't be too hard to compute. Draw it on a paper and you will see which coordinates you have to take ;)
-
sf::Rect::Intersect is in SFML 1.6 too ;)