Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a simple OpenGL game and I was looking for some simple collision detection library for objects like squares, triangles and circles. Any suggestions?

PS: Preferably a library that is very well documented and provide examples of 2D collision detections.

share|improve this question
up vote 5 down vote accepted

Box2D is very popular and well documented with lots of examples. Of course it's a full on physics library so it'll give you a good amount of flexibility for expanding later if you want. But you don't need to use those features if you don't want them.

For learning more about the algorithms and how to implement them yourself you can check this out.

Additionally this is a nice resource for showing how to detect intersections between various shapes. Which plays an important role in collision detection.

share|improve this answer

I think box2d is best 2d physic engine. Which can easily provide collision detection.

share|improve this answer

theoretically, you could store the position of the objects you want to detect collision with in an array.

then just have a simple Boolean(or even void if the game is simple enough) to detect whether a collision has taken place between the object your checking and your sprite/other object that could be doing the colliding.


int checkCollision()
for(int I=0; I<maxObjects; I++)
      if(object1_x >= object[I] && object1_x <= object[I] + object[I].width )
           return 1;
  return 0;

this is really messy, but if you want to come up with your own method of detecting collision, you could do something along the lines of that.

I do however recommend using Box2D, much easier.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.