Asteroids bullet collision

well I am trying to get a bullet to hit an enemy ship and destroy it. I am having trouble getting the collision float x_two values and y_two values to be correct. here is my code

	float offsets[4][2] = { {0.0f, 0.0f}, {-5.0f, -5.0f}, {0.0f, 10.0f}, {5.0f, -5.0f} };
	float cosA = cos(shipenemyAngle);
	float sinA = sin(shipenemyAngle);
	for (int i = 0; i < 4; i++)
		glVertex3f(offsets[i][0] * cosA - offsets[i][1] * sinA, offsets[i][0] * sinA + offsets[i][1] * cosA, 0.0f);

void coll_ship_one()
	//draw bullet
	float x = (0.0f * cos(shipAngle) - 10.0f * sin(shipAngle)*up); 
	float y = (0.0f * sin(shipAngle) + 10.0f * cos(shipAngle)*up);
	float oWidth=2.0f;
	float oHeight=2.0f;
	//draw ship
	float xTwo=10.0f;
	float yTwo=0.0f;
	float oTwoWidth= 10.0f;
	float oTwoHeight=15.0f;

	if (checkCollide(x, y, oWidth, oHeight, xTwo, yTwo, oTwoWidth, oTwoHeight) == 1)

Well I have drawn 2 ships on the screen. They can move and shoot bullets. I want to determine the distance between a bullet and the enemy ship. I am using the distance formula.

can I get some help on my problem?

probably not. you posted some incomplete, incomprehensible code.

1 Like