simple openGL/GLUT question

Started by
0 comments, last by Mucman 22 years, 8 months ago
I have a simple program that draws two triangles on a screen. I am trying to make a clone of the Combat game from the Atari 2600. When I use my controls, (keys) I can move the triangle and make it go faster and turn etc... The only problem is that the 2nd triangle object that I have made turns and follows the 1st triangle! I have made a class called GLob, and I use this draw() function in the display function called by the Idle function.

void GLob::draw()
{
    if (velocity > 0.0f )
       this->moveForward();

    glTranslatef(center.x,center.y,0.0f);
    glRotatef(angle,0.0f,0.0f,1.0f);
    glBegin(GL_TRIANGLES);
       glVertex3f((2.0f*size) , 0.0f, 0.0f);
       glVertex3f( - size,  size, 0.0f);
       glVertex3f( - size,  - size, 0.0f);
    glEnd();
}




void display ( void )   // Create The Display Function
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer
	glLoadIdentity();									// Reset The Current Modelview Matrix
   glTranslatef(0.0f,0.0f,-50.0f);

   tank.draw();

   tank2.draw();

   glutSwapBuffers ( );


  // Swap The Buffers To Not Be Left With A Clear Screen
}
 
I am really new at this (as you can probably tell), but I couldn''t find anyting on how to move two independent objects. Thanks a whole bunch!
"You won't get wise with the sleep still in your eyes." - Neil Peart
Advertisement
Nevermind, I figured it out... good ol push and pop matrix.
"You won't get wise with the sleep still in your eyes." - Neil Peart

This topic is closed to new replies.

Advertisement