I want to make a simple program that would load a box as a reference point and allow the user to move around with six keys: 2 to look up/down, 2 to look left/right, and 2 more to move forward and backward. First, I tried to make a simple program that would allow the user to move forward and backward. I am using GLUT, so I implemented the following into a keyboard event handler: (T = move forward, V = move backward)
case 'T': case 't': zPos -= 0.05; break; case 'v': case 'V': zPos += 0.05; break;
then I put the following into a callback function to render the scene:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPushMatrix(); glTranslatef( 0.0, 0.0, -5.0 ); glutSolidCube( 1.0 ); glPopMatrix(); glTranslatef( 0.0, 0.0, -zPos ); glutSwapBuffers();
For some weird reason, say I press T a few times, it’ll move forward, but then when I hit V, it’ll keep moving forward to a point before it starts moving backward. The same is true when I flip the order. I am not sure why the controls are unyielding…can someone help me out?
[This message has been edited by Big_al482 (edited 05-20-2001).]