Advertisement Jump to content
Sign in to follow this  

Collsion detection with other objects

This topic is 2500 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


I am trying to implement some collision detection on two OpenGL objects a player and a triangle. I have a collision detection method in a class that draws a triangle:

bool CTriangleCollision::testCollision (float x, float y, float z, float r)
float d = sqrt ((x-m_xCPos)*(x-m_xCPos) + (y-m_yCPos)*(y-m_yCPos));

if(d < r)
return true;
return false;

The parameter x has the x position of the player passed in and the same with the y parameter.

I then call this in main in my loop:

if(g_TriangleCollision.testCollision(g_Player1.getPosX(), g_Player1.getPosY(), 0 ,250))
else{ }

I have used the delete function it has flagged an error and I am not sure about the condition for my collision detection function feedback on those would be good

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!