Advertisement Jump to content
Sign in to follow this  

opengl and collision detection

This topic is 4102 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

can anyone help me to understand this code, I would really like to look at a picture of this code and how it is applied if x1 + width1 > x2 and y1 + height1 > y2 and x1 < x2 + width2 and y2 < y2 +height2 then collision!

Share this post

Link to post
Share on other sites
#include <iostream>
#include <player.h>

using namespace std;

int main()

int height;
int width;

if (height < 1)

player.height = 1;

if (width < 1)

player.width = 1;

return 0;

Share this post

Link to post
Share on other sites
Where did you find that code? And what exactly are you having problems with? To me it's a fairly straight-forward piece of (psuedo-)code - all it does is checking if two axis-aligned boxes collide. It first looks at the horizontal axis - do the projections of the boxes on that axis overlap? If so, they might collide, so let's look at the vertical axis - do their projections on that axis overlap as well? If so, then they collide.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!