SFML Collision Detection

Sep 4, 2013 at 7:41am
Just curious which type of collision detection would you recommend in sfml game programming out of: Distance Based, Bounding Box, Pixel perfect?
Sep 4, 2013 at 1:25pm
Why not use multiple collision detection methods?

I believe SFML comes with built-in collision detection using sf::FloatRect, I believe the methods are called "intersects" and "contains".
Sep 4, 2013 at 1:55pm
closed account (o1vk4iN6)
Generally there is some sort of broad-phase which is a simplification of complex objects, generally axis aligned bounding box is used (sphere's can be used as well and doesn't require rotation). So if you want pixel perfect you would give your sprites a bounding box and put them in some sort of spacial partitioning to only test them in the same area. This really depends on the scope though, if you only plan to have 100 objects, you can probably get away with just using bounding boxes without hitting a performance wall.
Last edited on Sep 4, 2013 at 1:55pm
Sep 4, 2013 at 5:21pm
closed account (3qX21hU5)
SFML gives a example of collision detection on the github page https://github.com/LaurentGomila/SFML/wiki/Source%3A-Simple-Collision-Detection-for-SFML-2 .

It includes BoundingBox BoundingCircle and PixelPerfect collision tests. You could probably adapt this into your game and improve upon it. There really isn't a one size fits all for collision detection when it comes to games. Use what works best for you.
Topic archived. No new replies allowed.