Jump to content
  • Advertisement
phil67rpg

shooting bullets

Recommended Posts

I have almost solved my next problem. I got my bullet to rotate with the ship but it only moves straight up when it is fired. my question is how do I get it to move following the nose of the ship.

void drawBullet()
{
	glPushMatrix();
	glColor3f(1.0f, 0.0f, 0.0f);
	glLoadIdentity();
	glTranslatef(50.0f, 0.0f, 0.0f);
	glTranslatef(dx, dy, 0.0f);
	glPointSize(2.0f);
	glBegin(GL_POINTS);
	float offsets[1][2] = { {0.0f, 10.0f} };
	float cosA = cos(shipAngle);
	float sinA = sin(shipAngle);
	for (int i = 0; i < 1; i++)
		glVertex3f(offsets[i][0] * cosA - offsets[i][1] * sinA, offsets[i][0] * sinA + offsets[i][1] * cosA + up, 0.0f);
	glEnd();
	glPopMatrix();
}

 

Share this post


Link to post
Share on other sites
Advertisement

well I have solved  this problem as well,  here is my code

void drawBullet()
{
	glPushMatrix();
	glColor3f(1.0f, 0.0f, 0.0f);
	glLoadIdentity();
	glTranslatef(50.0f, 0.0f, 0.0f);
	glTranslatef(dx, dy, 0.0f);
	glPointSize(2.0f);
	glBegin(GL_POINTS);
	float offsets[1][2] = { {0.0f, 10.0f} };
	float cosA = cos(shipAngle);
	float sinA = sin(shipAngle);
	for (int i = 0; i < 1; i++)
		glVertex3f(offsets[i][0] * cosA - offsets[i][1] * sinA*up, offsets[i][0] * sinA + offsets[i][1] * cosA*up, 0.0f);
	glEnd();
	glPopMatrix();
}

 

you  can also close this thread.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!