import objectdraw.*;

// FallingObject class to encapsulate the behavior of ActiveObjects that
// fall until they reach a certain y-position then disappear
public class FallingObject extends ActiveObject {

        protected static final int DELAY_TIME = 33;

        protected int fallToPos;  // bottom y position

        protected double ySpeed;  // speed of fall

        protected Drawable2DInterface object;  // "thingy" to fall

        // Parameters: thePos - how far down the object should fall
        //             theSpeed - how far to fall each time around
        public FallingObject(int thePos, double theSpeed) {
                ySpeed = theSpeed;
                fallToPos = thePos;
        }

        public void run() {
                while (object.getY() < fallToPos) {
                        pause(DELAY_TIME);
                        object.move(0, ySpeed);
                }
                object.removeFromCanvas();
        }
}
