import objectdraw.*;
import java.awt.*;
/*
 * 
 * Example FallingSnow: the main class that creates clouds, which in turn
 * create falling snowflakes.
 *
 * Jim Teresco, Siena College, CSIS 120, Fall 2011
 * Based on example from CSCI 134, Williams College
 *
 * $Id: Snow.java 1576 2011-03-24 04:32:40Z terescoj $
 */

// Program which creates clouds which create snow when the user clicks
public class Snow extends WindowController {

    // constants for the moon size and location
    private static final double MOON_INSET = 50;
    private static final int MOON_SIZE = 70;

    // sizes and locations for the bricks
    private static final double BRICK_LINE = 40;  // from bottom
    private static final double BRICK_HEIGHT = 12;
    private static final double BRICK_WIDTH = 30;
    private static final double BRICK_SPACING = 3;

    // colors of the sky, mortar, and brick
    private final Color NIGHTSKY = new Color(50, 50, 100);
    private final Color MORTAR = new Color(200, 200, 200);
    private final Color BRICKRED = new Color(150, 40, 40);

    // image of the snow
    private Image snowPic;

    public void begin() {

        // where to draw next brick
        double brickPosition;

        // get leaf picture
        snowPic = getImage("snow.gif");

        // draw solid sky, mortar, and moon
        new FilledRect(0, 0, canvas.getWidth(), canvas.getHeight() - BRICK_LINE, canvas).setColor(NIGHTSKY);
        new FilledRect(0, canvas.getHeight() - BRICK_LINE, canvas.getWidth(), 
                       canvas.getHeight(),
                       canvas).setColor(MORTAR);
        new FilledOval(MOON_INSET,MOON_INSET,MOON_SIZE,MOON_SIZE,
                       canvas).setColor(Color.white);

        // add the bricks
        brickPosition = 0;
        while ( brickPosition < canvas.getWidth() ) {
            new FilledRect(brickPosition, canvas.getHeight() - BRICK_LINE,
                           BRICK_WIDTH, BRICK_HEIGHT,
                           canvas).setColor(BRICKRED);

            brickPosition = brickPosition + BRICK_WIDTH + BRICK_SPACING;
        }

    }

    public void onMouseClick(Location point) {
        // make a new snow-dropping cloud when the user clicks
        new Cloud(snowPic, canvas);
    }
}

