title: Vector Motion in Java
body: <p>So, I'm  making a game where you are to outrun enemies. Instead of having the enemies move at only up, down, left, right, and at 45 degree angles, I want the enemy to take the shortest linear path towards the player. Here's my code:</p>
  
  <pre><code>public void moveEnemy() {
      if (player.pos.x &gt; enemy.pos.x) {
      enemy.vel.x = 3;
      }
      if (player.pos.x &lt; enemy.pos.x) {
      enemy.vel.x = -3;
      }
      if (player.pos.y &gt; enemy.pos.y) {
      enemy.vel.y = 3;
      }
      if (player.pos.y &lt; enemy.pos.y) {
      enemy.vel.y = -3;
      }
      if (player.pos.x == enemy.pos.x) {
      enemy.vel.x = 0;
      }
      if (player.pos.y == enemy.pos.y) {
      enemy.vel.y = 0;
      }
  }
  </code></pre>
  
  <p>So, what this does is sets the velocity in cardinal directions. What could I do to make this more accurate?</p>