> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://hewitt.sketchpad.cc/sp/pad/view/ro.lFui-wd6SCO/rev.2
 * 
 * authors: 
 *   Tessa Schorsch

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



// Three different colored bouncing balls on a black background

float x= 200;  //this float x,y is the points that the circles start at.
float y= 0;

float xx=100;
float yy=0;

float xxx=300;
float yyy=0;

float speed = 0;    // Speed that the balls are moving

float gravity= 0.1; // power of gravity 

//an array is like a variable that can hold a list of values
int[] r = {50,40,230}; 
int[] g = {200,200,230};
int[] b = {50,200,10};

void setup() {
size(400,400); 

}

void draw () {
  background(0);
  
  
  //instead of 3 separate fills and ellipses, you can use 1 set and loop it 3 times with changing values
  for(int i = 0;i<3;i++) {
    fill(r[i],g[i],b[i]);
    ellipse(xx+i*100,y,50,50);
  }
  
  y=y+speed;            //Seting up speed and gavity compared to the three differet y's
  yy=y+speed;
  yyy=yy+speed;
  speed=speed+gravity;
  
  if (y>height) {
    speed=speed*-0.95;  // this conroals decreasing speed of the balls everytime they bounce
  }
   if (yy>height) {
    speed=speed*-0.95;
  }
   if (yyy>height) {
    speed=speed*-0.95;
  }
}