Plane game project

I am using a collision function to call a collision function but it does not call the collision function properly. when the bullet hits the enemy ship it does not display the collision function.

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_one;
	float y = 0.0f+vertical_one;
	float oWidth = 0.125f;
	float oHeight = 0.125f;
	//draw plane
	float xTwo = -5.0f+horizontal+up_two;
	float yTwo = 0.0f+vertical;
	float oTwoWidth = 1.0f;
	float oTwoHeight = 1.0f;

	if (checkCollide(x, y, oWidth, oHeight, xTwo, yTwo, oTwoWidth, oTwoHeight) == 1)
	{
		drawcollision_one();
	}
}

This isn’t an OpenGL question.

Consider doing more reading on computing collisions. Should you decide to post someplace (like www.gamedev.net) which includes discussion of collision detection techniques, you should post relevant code. For instance, you say that your collision function isn’t called properly, yet you show no code in your example which could even potentially call it.

Another related thread on this, presumably:

1 Like