Original Post
Can someone please help me on this code for collision detection im trying to get to work cus ive been trying for ages and when i try to use it, it works ok for the y co-ords but it says there is a collision anywhere on the along the x axis so an object will say its been hit when its at the right hieght but not if the x co-ords are the same please help. o yeh Obj is a structure that holds the x and y co-ords of an object.
int DetectCollisions( Obj quad1, Obj quad2 )
{
float quadWidth = 0.5f;
float quadHeight = 0.5f;
if ( quad1.y <= (quad2.y + quadHeight) && quad1.x <(quad2.x + quadWidth) && (quad1.x + quadWidth) > quad2.x )
{
// collision occured
return 1;
}
return 0;
}
thanks for any help sorry about the indentation and layout of the code.
Chris