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

/*
 * A simple basketball program.  It adds 2 points to 
 * a displayed score whenever the
 * mouse is clicked in the oval.
 */
public class Basketball extends WindowController {
    // Location of the display
    private static final int DISPLAY_X = 150;
    private static final int DISPLAY_Y = 200;
    private static final int DISPLAYSIZE = 16; // in pixels

    // Location and dimensions of the hoop
    private static final int HOOPTOP = 50;
    private static final int HOOPLEFT = 160;
    private static final int HOOPWIDTH = 100;
    private static final int HOOPHEIGHT = 60;

    // the Text object which displays the count
    private Text display;

    // the oval that represent the hoop
    private FramedOval hoop;

    // the number of points
    private int score;

    /*
     * Initialize the counter and the text message.
     */
    public void begin() {
        score = 0;
        display = new Text("Your score is 0", DISPLAY_X, DISPLAY_Y, canvas);
        display.setFontSize(DISPLAYSIZE);

        hoop = new FramedOval(HOOPLEFT, HOOPTOP, 
                              HOOPWIDTH, HOOPHEIGHT, canvas);
    }

    /*
     * Increment the counter and update the text if player scores.
     */
    public void onMouseClick(Location point) {
        if (hoop.contains(point)) {
            score = score + 2;
            display.setText("Your score is " + score);
        }
    }
}
