I have incorporated your code, but I cannot get the ships to rotate around their centers and to follow their noses when moving up and down. here is my code so far.
void
DrawShip(GLfloat position_X,GLfloat position_Y, GLfloat position_Z, GLfloat rotation,GLfloat color)
{
glPushMatrix();
glTranslatef(
position_X, position_Y, position_Z);
glRotatef(
rotation,0.0f,0.0f,1.0f);
glColor3f(
color,0.0f,0.0f);
glBegin(
GL_LINE_LOOP);
glVertex3f(-1.5f,-0.25f,0.0f);
glVertex3f(-1.75f,-0.5f,0.0f);
glVertex3f(-2.0f,-0.5f,0.0f);
glVertex3f(-1.5f,0.5f,0.0f);
glVertex3f(-1.0f,-0.5f,0.0f);
glVertex3f(-1.25f,-0.5f,0.0f);
glVertex3f(-1.5f,-0.25f,0.0f);
glEnd();
glPopMatrix();
}
void
Render(void)
{
glClear(
GL_COLOR_BUFFER_BIT);
DrawShip(ship_01_POSITION_X,ship_01_POSITION_Y,ship_01_POSITION_Z,ship_01_ROTATION,ship_01_COLOR);
DrawShip(ship_02_POSITION_X,ship_02_POSITION_Y,ship_02_POSITION_Z,ship_02_ROTATION,ship_02_COLOR);
glutSwapBuffers();
}
here is my movement code
void
ship_left_two()
{
ship_01_ROTATION+=2.5f;
}
void
ship_right_two()
{
ship_01_ROTATION-=2.5f;
}
void
ship_up_two()
{
ship_01_POSITION_Y+=0.1f;
}
void
ship_down_two()
{
ship_01_POSITION_Y-=0.1f;
}
void
ship_up()
{
ship_02_POSITION_Y+=0.1f;
}
void
ship_down()
{
ship_02_POSITION_Y-=0.1f;
}
void
ship_left()
{
ship_02_ROTATION+=2.5f;
}
void
ship_right()
{
ship_02_ROTATION-=2.5f;
}