title: OpenGL: Moving around 3D Scene
body: <p>I am trying to move a vehicle around the scene using arrow keys. I am able to rotate the vehicle around itself using left/right keys, but when I attempt to move forward/backward, it only follows a single axis no matter which way the face of the vehicle is facing.</p>
  
  <pre><code>glPushMatrix();
  
      // movement
      glTranslatef(movement, 0.0, 0.0);
  
      // turning
      glTranslatef(base, 0.0, 0.0);
      glRotatef(turnAngle, 0.0, 1.0, 0.0);
      glTranslatef(-base, 0.0, 0.0);
  
      drawCar();
  
  glPopMatrix();
  </code></pre>
  
  <p>At the moment, I only increment or decrement <code>movement</code> on up/down keys. From what I understand, the reason my object moves on a single axis is because I'm only translating by <code>movement</code> on the x-axis. How do I track where the front of my vehicle is facing when turned and move 'forward' in that direction?</p>