title: Vehicle direction OpenGL
body: <p>This is a uni assignment so I am unable to show you large chunks of code, however the main issue I'm having is that I am trying to track which direction the car is travelling in (either towards positive x or negative x). I am working in c++. In my draw function which runs and updates every frame I have something like this</p>
  
  <pre><code>static double dx;
  dx = vehicle-&gt;getX()-dx;
  </code></pre>
  
  <p>getX() is working fine and gets the current position of the vehicle. Any ideas on why I always get a positive answer while traveling forward, yet when I reverse dx just goes down rather than change to negative which is what I want.</p>