Jump to content
  • Advertisement
Sign in to follow this  
OgbobeBuko

Moving Object from one position to the other

This topic is 2555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

this is supposed to be easy...but i dont understand what i am doing wrong....trying to move my object from one position to another in an animation...but it just keeps moving and wont stop....any ideas on how i could achieve this ....a short snippet would be helpful thanks





glPushMatrix();
glTranslatef(pos1X,Pos1Y,Pos1Z);
glRotatef( rot_a, 0, 0, 1 );
Draw_A();
glPopMatrix();

glPushMatrix();
glTranslatef(pos2X,Pos2Y,Pos2Z);
glRotatef( rot_b, 0, 0, 1 );
Draw_B();
glPopMatrix();

void idle(){

if ( animate==false ){
if (pos1X > 0)
pos1X -= 0.020f;
}
if (pos1X == 0)
animate=true;

rY += 0.02;
glutPostRedisplay();
}

Share this post


Link to post
Share on other sites
Advertisement
Hello,

If your object never stops moving, means that pos1X never gets to be exactly 0. Maybe if you put the condition like this. This is just a guess.



if (pos1X < 0)
animate=true;



Hope it helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!