title: How do you move an object in a wavy pattern?
body: <p>I know the following code will move an object in a straight line. How can I get the object to travel in a wavy line? I know that something extra is required for the <code>x</code> variable.</p>
  
  <pre><code>public void draw(Graphics2D g) 
          {
              g.setColor(Color.WHITE);
              g.fillOval ((int) (x - r), (int) (y - r), (int)
                      (2 * r),
                      (int) (2 * r));
  
              y++;
  
  
              if (y - r &gt; height)
                  y = -r;
          }
  </code></pre>