Jump to content

  • Log In with Google      Sign In   
  • Create Account

simple openGL/GLUT question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Mucman   Members   -  Reputation: 122

Like
Likes
Like

Posted 02 August 2001 - 12:01 PM

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!

Sponsor:

#2 Mucman   Members   -  Reputation: 122

Like
Likes
Like

Posted 02 August 2001 - 12:47 PM

Nevermind, I figured it out... good ol push and pop matrix.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS