Hey all, my first post here, am studying SFML 2.0 at university but as I dont want to annoy my tutor with every question I hope you don't mind helping me out
I have position = velocity * DeltaTime working wonderfully and objects like the player within their own class so the next step is figuring this out =)
As I understand it would you draw a rectangle over your sprite to check if it collides with another rectangle? Or does the IntRect of the sprite(the box you cut out) suffice for the rectangle needed to detect collision??
My tutor has provided this for an example but im still a little confused:
struct Rectangle
{
float top;
float left;
float bottom;
float right;
};
// Assumes y runs 'downward'.
bool Intersects(const Rectangle& r1, const Rectangle& r2)
{
if (r1.bottom < r2.top) return false;
if (r1.top > r2.bottom) return false;
if (r1.left > r2.right) return false;
if (r1.right < r2.left) return false;
// Rectangles must be intersecting!
return true;
}