I am made a lot of progress in my game but I have hit a small snag. in my code I am using an AABB collision detection. I have also used exit(0) to debug my code.it tells me where in my code where it is getting access to. I have put exit(0) in the AABB collision detection and it accesses it just fine. but when I put only drawcollision_one function in the AABB collision routine it does not draw my collision sprite animation. when I put drawcollision_one in the display function it works just fine. when the planes collide nothing happens but the exit(0) is accessed when the planes collide. here is the code I am working on.
void drawcollision_one()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[3]);
glBegin(GL_POLYGON);
glTexCoord3f(0.0f + screen, 0.0f, 0.0f);
glVertex3f(0.5f, -0.5f, 0.0f);
glTexCoord3f(0.167f + screen, 0.0f, 0.0f);
glVertex3f(0.5f, 0.5f, 0.0f);
glTexCoord3f(0.167f + screen, 1.0f, 0.0f);
glVertex3f(-0.5f, 0.5f, 0.0f);
glTexCoord3f(0.0f + screen, 1.0f, 0.0f);
glVertex3f(-0.5f, -0.5f, 0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void timer(int val)
{
screen += 0.1667f;
if (screen >= 1.0f)
{
screen = 1.0f;
}
glutPostRedisplay();
glutTimerFunc(500, timer, 0);
}
void coll_plane_one()
{
//draw bullet
float x = -5.0f + horizontal;
float y = 0.0f + vertical;
float oWidth = 1.0f;
float oHeight = 1.0f;
//draw plane
float xTwo = 5.0f + horizontal_one;
float yTwo = 0.0f + vertical_one;
float oTwoWidth = 1.0f;
float oTwoHeight = 1.0f;
if (checkCollide(x, y, oWidth, oHeight, xTwo, yTwo, oTwoWidth, oTwoHeight) == 1)
{
drawcollision_one();
}
}