Class BouncingBall

java.lang.Object
  |
  +--BouncingBall

public class BouncingBall
extends java.lang.Object

Class BouncingBall - a graphical ball that observes the effect of gravity. The ball has the ability to move. Details of movement are determined by the ball itself. It will fall downwards, accelerating with time due to the effect of gravity, and bounce upward again when hitting the ground. This movement can be initiated by repeated calls to the "move" method.

Version:
1.1 (23-Jan-2002)
Author:
Bruce Quig
, Michael Kolling (mik) , David J. Barnes

Constructor Summary
BouncingBall(int xPos, int yPos, int ballDiameter, java.awt.Color ballColor, int groundPos, java.awt.Canvas drawingCanvas)
          Constructor for objects of class BouncingBall
 
Method Summary
 void draw()
          Draw this ball at its current position onto the canvas.
 void erase()
          Erase this ball at its current position.
 int getXPosition()
          return the horizontal position of this ball
 int getYPosition()
          return the vertical position of this ball
 void move()
          Move this ball according to its position and speed and redraw.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BouncingBall

public BouncingBall(int xPos,
                    int yPos,
                    int ballDiameter,
                    java.awt.Color ballColor,
                    int groundPos,
                    java.awt.Canvas drawingCanvas)
Constructor for objects of class BouncingBall

Parameters:
xPos - the horizontal coordinate of the ball
yPos - the vertical coordinate of the ball
ballDiameter - the diameter (in pixels) of the ball
ballColor - the color of the ball
groundPos - the position of the ground (where the wall will bounce)
drawingCanvas - the canvas to draw this ball on
Method Detail

draw

public void draw()
Draw this ball at its current position onto the canvas.


erase

public void erase()
Erase this ball at its current position.


getXPosition

public int getXPosition()
return the horizontal position of this ball


getYPosition

public int getYPosition()
return the vertical position of this ball


move

public void move()
Move this ball according to its position and speed and redraw.