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

// program that 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 points

	// 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);
		}
	}

}
