Ball ball1;

Ball ball2;

float gravity = 0.10;

void setup() {

size(250,250);

smooth();


ball1 = new Ball(55,05,18);

ball2 = new Ball(110,52,33);

}

void draw() {

background(255,0,0);

ball1.display();

ball2.display();

//Move balls

ball1.update();

ball2.update();

}

class Ball{
//ball 1
float x=100; 
//ball 2
float y=0; 
// ball speed
float speed=0;

float w;

//Constructor

Ball(float tempX, float tempY, float tempW){

x=tempX;

y=tempY;

w=tempW;

speed=0;

}

void display(){


fill(130);

stroke(0);

ellipse(x,y,w,w);

}

void update(){

y = y + speed;


speed = speed + gravity;


if (y > height) {

speed = speed * -0.96;

}

}

}