Been searching for quite a while now and really struggling to find an easy way, or a good tutorial on how to create a collision detection system which can indicate what side on a box a collision has occurred.

I should specify that I am using SFML2 and their sprites class, this is what I currently use and it just picks up 2 sprites intersecting

//check rectangles for collision without taking into account where the collision is
bool Game::isRectCollision(sf::Sprite &sprite1, sf::Sprite &sprite2){

    sf::FloatRect r1=sprite1.getGlobalBounds();
    sf::FloatRect r2=sprite2.getGlobalBounds();
    return r1.intersects(r2);

  • \$\begingroup\$ I have always passed the object's movement speed as parameters as well. If object1.velocity.x > 0, for example, then object1 is coming from the left and colliding its right. I wonder if there are alternative ways, tho \$\endgroup\$
    – Mutoh
    Commented May 10, 2015 at 0:19

1 Answer 1


The Separating Axis Theorem might be what you're looking for.
Writing collision detection using SAT is easier than it seems and allows you to calculate handy things like where exactly they collided as well as the minimum translation vector. Highly recommended for shape collision detection.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .