movement
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
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:
then make an instance of it:
initialize it:
and when you draw your object:
and if you want it to move:
Hope this helps
- Mike
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement