import java.awt.Color;

import objectdraw.DrawingCanvas;
import objectdraw.FilledOval;

// FallingSleet class

public class FallingTomato extends FallingObject {

        // size of a sleet pellet
        private static final int SIZE = 40;
        private static final int SPLATTER_DELAY = 1000;

        private DrawingCanvas canvas;

        // initialize the instance variables and start the active object
        public FallingTomato(DrawingCanvas theCanvas, double x, double aSpeed, int aScreenHeight) {
                // first, call "up" to the constructor of the FallingObject class
                super(aScreenHeight - SIZE / 2, aSpeed);

                canvas = theCanvas;

                object = new FilledOval(x, -SIZE, SIZE, SIZE, canvas);
                object.setColor(Color.RED);

                start();
        }

        // we override the hitBottom method from FallingObject
    // since we want extra functionality
        protected void hitBottom() {

                // first, remember our x position
                double x = object.getX();

                object.removeFromCanvas();

                // but then a little extra
                FilledOval splat = 
                        new FilledOval(x - SIZE / 2, fallToPos, SIZE * 2, 
                                                   SIZE / 2, canvas);
                splat.setColor(Color.red);
                pause(SPLATTER_DELAY);
                splat.removeFromCanvas();
        }
}
