java.lang.Object | +--BouncingBall
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.
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 |
public BouncingBall(int xPos, int yPos, int ballDiameter, java.awt.Color ballColor, int groundPos, java.awt.Canvas drawingCanvas)
xPos
- the horizontal coordinate of the ballyPos
- the vertical coordinate of the ballballDiameter
- the diameter (in pixels) of the ballballColor
- the color of the ballgroundPos
- the position of the ground (where the wall will bounce)drawingCanvas
- the canvas to draw this ball onMethod Detail |
public void draw()
public void erase()
public int getXPosition()
public int getYPosition()
public void move()