Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

simple openGL/GLUT question

4: Adsense

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   

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!

#2 Mucman   Members   

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.