import objectdraw.*;

/**
 * Class representing a ball that just falls straight down until
 * it falls off the screen.
 * @author Kim Bruce
 *
 */

type FallingBall = {
   start -> Done
}

class ball.size (ballSize) inside (boundary) moveRange (min,max) 
                       hitBy (paddle) on (canvas)  {

    def xShift = 0
    def yShift = 8
    
    def pauseTime = 30  // time gap between moves of ball

    method start {
        def theBall = filledOval.at(boundary.location+(1@1)) 
                             size (ballSize,ballSize) on (canvas)
                             
      //  print("ball: {theBall.y}, canvas: {canvas.y}")
        animator.while{theBall.y < canvas.height} pausing (pauseTime) do {
            theBall.moveBy(xShift,yShift)
        } finally {
            theBall.removeFromCanvas
        }

    }
}