import objectdraw.*;
import java.awt.*;

public class FallingLeaf extends ActiveObject
{
   private static final int START_FAKE_Y = -80;  // ....

   private final int delayTime = 33;     // delay between leaf motions
  
   private int screenHeight;             // lowest point in window

   private double yspeed;				  // speed of fall

   private VisibleImage leaf;           // the leaf

   // construct leaf and put at top of screen at x from left
   public FallingLeaf(DrawingCanvas canvas, Image leafpic,
                      double x, double speed,
                      int aScreenHeight)
   {
      leaf = new VisibleImage(leafpic, 0,START_FAKE_Y ,canvas);
      leaf.move(x , - leaf.getHeight());

      yspeed = speed;
      screenHeight = aScreenHeight;

      start();
   }

   // Leaf falls to ground
   public void run()
   {
      while (leaf.getY() < screenHeight )
      {
          leaf.move(0,yspeed);
          pause(delayTime);
     }

      leaf.removeFromCanvas();
   }

}