glVertex3f(-5.0625f+cos(angle)*up+horizontal+space_two, 0.625f + sin(angle)*up + vertical + space, 0.0f);
glTexCoord3f(1.0f, 0.0f, 0.0f);
glVertex3f(-5.0625f + cos(angle)*up + horizontal + space_two, 0.5f + sin(angle)*up + vertical + space, 0.0f);
glTexCoord3f(1.0f, 1.0f, 0.0f);
glVertex3f(-4.9375f + cos(angle)*up + horizontal + space_two, 0.5f + sin(angle)*up + vertical + space, 0.0f);
glTexCoord3f(0.0f, 1.0f, 0.0f);
glVertex3f(-4.9375f + cos(angle)*up + horizontal + space_two, 0.625f + sin(angle)*up + vertical + space, 0.0f);
here is the code for my bullet , I want to rotate the bullet around my plane sprite with the same place as my plane sprite is facing.
can I please get some help
pbivens
October 16, 2018, 12:53pm
3
well I have worked on my code, I am stuck on how to rotate the bullet sprite around the plane sprite
glPushMatrix();
glBegin(GL_POLYGON);
glTexCoord3f(0.0f, 0.0f, 0.0f);
glVertex3f(-5.0625f*cos(angle) - 0.5f*sin(angle), -5.0625f*sin(angle) + 0.5f*cos(angle)+up, 0.0f);
glTexCoord3f(1.0f, 0.0f, 0.0f);
glVertex3f(-5.0625f*cos(angle) - 0.625f*sin(angle), -5.0625*sin(angle) + 0.625f*cos(angle)+up, 0.0f);
glTexCoord3f(1.0f, 1.0f, 0.0f);
glVertex3f(-4.9375f*cos(angle) - 0.625f*sin(angle), -4.9375f*sin(angle) + 0.625f*cos(angle)+up, 0.0f);
glTexCoord3f(0.0f, 1.0f, 0.0f);
glVertex3f(-4.9375f*cos(angle) - 0.5f*sin(angle), -4.9375*sin(angle) + 0.5f*cos(angle)+up, 0.0f);
glEnd();
glPopMatrix();
I am still working on rotating my bullet around my plane sprite I have made some progress. however when move the plane down the bullet is drawn toward the top middle of the screen. when I move the plane to the left the bullet is drawn toward the middle of the left of the screen. although the bullet does move in the same direction as the plane is facing, at least I have solved that problem. I think the problem is in the glRotatef function. here is my code so far
can I get some help here is my code so far
void drawbullet_one()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[2]);
glPushMatrix();
if (rotate == 0.25f)
{
angle = 0.0f;
}
if (rotate == 0.75f)
{
angle = 180.0f;
}
if (rotate == 0.5f)
{
angle = 90.0f;
}
if (rotate == 0.0f)
{
angle = 270.0f;
}
glRotatef(angle, 0.0f, 0.0f, 1.0f);
glTranslatef(0.0f, 0.0f + up, 0.0f);
glBegin(GL_POLYGON);
glTexCoord3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0625f+horizontal, 0.0625f+vertical, 0.0f);
glTexCoord3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.0625f+horizontal, 0.0625f+vertical, 0.0f);
glTexCoord3f(1.0f, 1.0f, 0.0f);
glVertex3f(-0.0625f+horizontal, -0.0625f+vertical, 0.0f);
glTexCoord3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0625f+horizontal, -0.0625f+vertical, 0.0f);
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_2D);
}
is this too hard of a problem, can I please get some help.
Read this:
[ul]
[li]Chapter 3: Viewing (OpenGL Programming Guide, Ver. 1.1) [/li][/ul]
Pay particularly close attention to the Viewing and Modeling Transformations section.
If you don’t understand something after reading it over a few times, feel free to ask.
pbivens
November 11, 2018, 12:31pm
8
I have read ch3. what do I do next?
pbivens
November 11, 2018, 6:53pm
9
YEAH!!! I solved my problem thanks for all the help