moving polygons
Hello again, its the one who drew the square off the screen
Now I`ve advanced onto polygons.
My problem is that I want to know how to move a polygon like a car by pressing, say, the up arrow. If possible I would like to know how to move it around like a car, moving in the x axis and the z axis at the same time.
thanks in advance
Baldur
If you are using nehes code you should add the following lines
in the drawing function before you use glBegin() and the line
glTranslatef( xPos , yPos , zPos )
make sure you declare these at the top of the program as global varibles.
Then in the piece of code where you have swapbuffers(hDC)
add the next couple of lines
if (keys[VK_LEFT])
xPos -= 0.2f;
if (keys[VK_RIGHT])
xPos += 0.2f;
That moves left and right
You have to add
bool keys[256] ; to the top of the prog..
Another idea is to read through nehes tuts as this is explained in details
in the drawing function before you use glBegin() and the line
glTranslatef( xPos , yPos , zPos )
make sure you declare these at the top of the program as global varibles.
Then in the piece of code where you have swapbuffers(hDC)
add the next couple of lines
if (keys[VK_LEFT])
xPos -= 0.2f;
if (keys[VK_RIGHT])
xPos += 0.2f;
That moves left and right
You have to add
bool keys[256] ; to the top of the prog..
Another idea is to read through nehes tuts as this is explained in details
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement