title: Smooth Movement Issues with Processing 4
body: <p>I am writing a program where small 'birds' move around and follow your cursor. The instances don't rotate or anything fancy and I'm having a very unusual problem.</p>
  <p>If the instance is on the same X-level or Y-level it oscillates. I've come across this problem with boundaries and movement before so I tried to take a similar approach.</p>
  <pre><code>void move() {
      
      if (xPos == mouseX) {
        xPos += 0;
      } else if (xPos &lt; mouseX) {
        xPos += speed;
      } else {
        xPos -= speed;
      }
      
      if (yPos == mouseY) {
        yPos += 0;
      } else if (yPos &lt; mouseY) {
        yPos += speed;
      } else {
        yPos -= speed;
      }
  
      xPos = (xPos &gt; mouseX) ? xPos - speed : xPos + speed;
      yPos = (yPos &gt; mouseY) ? yPos - speed : yPos + speed;
    }
  </code></pre>
  <p>The movement is only smooth when both versions run at the same time. I've tried rearranging the '&gt;' and '&lt;' signs to no avail.</p>
  <p>Is there any part of this code I could remove to stop it repeating itself?</p>
  <p>Thanks :)</p>