title: Car Steering - OpenGL
body: <p>I'm creating a racing car game and am having trouble figuring out how to get steering to work. I have a basic race 2D race course that is built in a 3D environment. The program only uses x and y, with z being 0.</p>
  
  <p>My race course consists of a road that is 29 units wide in the x-axis and two long tracks that are 120 units long in the y direction. At 120 units in the y-axis there is a 180 degree turn. You can think of the course as looking similar to a nascar styled race course.</p>
  
  <p>I'm trying to set my car's steering so that it can turn realistically when I reach the 180 degree turns. I'm using two variables that separately control the x / y positions, as well as two variables for the x / y velocities. My code at the moment is as follows:</p>
  
  <pre><code>public void steering(){
      double degreesPerFrame = 180 / (2*30); //180 degrees over 30 fps in 2s
      velocityX = velocityX * -1 * Math.cos(degreesPerFrame);
      velocityY = velocityY * -1 * Math.sin(degreesPerFrame);
      double yChange = Math.sin(degreesPerFrame) * velocityY;
      double xChange = Math.cos(degreesPerFrame) * velocityX;
      x += xChange; //change x position
      y += yChange; //change y position
  }
  </code></pre>
  
  <p>I'm not completely sure how I can get my steering to turn properly. I'm stuck at the moment and not sure what I would need to change in my function to get steering working properly.</p>