title: Acceleration equation
body: <p>I'm making a game in which an object needs to accelerate and decelerate in a certain way.</p>
  <p>I have 5 variables:</p>
  <ol>
  <li><code>velX</code> (current x velocity),</li>
  <li><code>velY</code> (current y velocity),</li>
  <li><code>desiredVelX</code> (desired velX value),</li>
  <li><code>desiredVelY</code> (desired velY value), and</li>
  <li><code>accelTime</code> (how fast the object accelerates).</li>
  </ol>
  <p>Basically, I want an equation that can accelerate <code>valX</code> to <code>desiredValX</code> when <code>desiredValX = 10</code>, <code>0</code>, and <code>-10</code> when called 128 times a second. And an identical equation for the Y based variables.</p>
  <p>I really have no idea how to generate equations for problems like these so some insight into that would be appreciated too.</p>
  <p>Here's my current code:</p>
  <pre><code>public class Player {
  
  private double x;
  private double y;
  private double velX;
  private double velY;
  private double desiredVelX;
  private double desiredVelY;
  private double accelTime = 128 / 2; //Half second to accelerate fully
  
  
  public Player(double x, double y, Game g)
  {
      this.x = x;
      this.y = y;
  }
  
  public void tick()
  {
      if(velX!=desiredVelX){
          *Equation*
      }
  
      if(velY!=desiredVelY){
          *Equation*
      }
  
      x+=velX;
      y+=velY;
  }
  
  public void accel(boolean d, double speed){
      if(d){desiredVelX = speed;}
      else{desiredVelY = speed;}
  }
  }
  </code></pre>