In the code below I am trying to make a ball bounce up and down. The problem is that the ball is painting itself over and over and forming a line rather than a ball moving in a line.
I’m thinking that I need to erase the ball after it draws itself.
public void paint(Graphics g) {
if (bouncing) {
g.setColor(Color.blue);
g.drawOval(x, y, 10, 10);
//erase oval here
}
}
NOTE: Method paint is being called over and over
Paint the entire background first …