Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


movement


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
2 replies to this topic

#1 treds1   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2001 - 08:06 AM

how can i get an object to move n opengl in c++, can get it to move along x axis or y axis and xy, but not freely. any ideas?? cheers nick

Sponsor:

#2 mkaltner   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2001 - 11:58 AM

I''m not sure I know EXACTLY what you want to achieve but moving an object is quite simple.

When you draw an object, you have to know where to draw it, correct?

What I would do is create a structure called coordinate:

typedef struct
{
float xPos;
float yPos;
float zPos;
} coordinate;

then make an instance of it:

coordinate square;

initialize it:

square.xPos = 0.0f;
square.yPos = 0.0f;
square.zPos = 0.0f;

and when you draw your object:

...
glTranslatef(square.xPos, square.yPos, square.xPos);
...

and if you want it to move:

if (keyDown[VK_RIGHT]) {
...
square.xPos += 1.0f; // or whatever increment you want
...
}


Hope this helps

- Mike

#3 treds1   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2001 - 11:03 PM

thats basically what i allready have.

basically i have a car which i want to be able to drive along but can not get it to turn




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