Skip to main content
GameDev.net gamedev.net
🔒 Locked

shooting bullets

Started by phil67rpg Nov 6, 2019 at 5:23 PM 5 replies 3.6k views
Original Post
phil67rpg
phil67rpg

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();
}


Lactose
Lactose

You claimed to solve this almost a year ago.


Hello to all my stalkers.
fleabay
fleabay
33 minutes ago, Lactose said:

You claimed to solve this almost a year ago.

You clearly don't understand the concept of a running gag.

🙂🙂🙂🙂🙂<←The tone posse, ready for action.
phil67rpg
phil67rpg

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.

phil67rpg
phil67rpg

you can close this thread

Tom Sloper
Tom Sloper

You can stop asking to have threads closed.

-- Tom Sloper    --      sloperama.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.