// CS 1 demo to play the game of Pong
// This version constrains the paddle so it doesn't go off 
// left side of court

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

public class Pong extends WindowController{

    // the position and dimensions of the court
    private static final int COURT_LEFT = 50,
                             COURT_TOP = 50,
                             COURT_HEIGHT = 300,
                             COURT_WIDTH = 250;
                             
    // dimensions of the paddle
    private static final int PADDLE_WIDTH = 50,
                            PADDLE_HEIGHT = 20;

    private FilledRect paddle;      // the paddle
    private FramedRect boundary;    // the boundary of the playing area.
    
    // make the playing area and paddle
    public void begin()
    {
        boundary = new FramedRect(COURT_LEFT, COURT_TOP,
                                  COURT_WIDTH, COURT_HEIGHT,
                                  canvas);
        
        paddle = 
            new FilledRect(COURT_LEFT + (COURT_WIDTH-PADDLE_WIDTH)/2,
                           COURT_TOP + COURT_HEIGHT - PADDLE_HEIGHT -1,
                           PADDLE_WIDTH, PADDLE_HEIGHT,
                           canvas);
    }
    
    // make a new ball when the player clicks
    public void onMouseClick(Location point)
    {
         new MovingBall(canvas, paddle, boundary);
    }
    
    // Move paddle in response to mouse move.
    // Keep it from going beyond left edge of court
    public void onMouseMove(Location point)
    {
        if ( point.getX()