int bar1X = 500;
int bar2X = 200;
float gap1Y = random(100,300);
float gap2Y = random(100,300);
float birdY = 250;
float speed = -5;
void setup()
{
  size(500,500);
}
void draw()
{
  background(255);
  drawBars();
  moveBars();
  checkForDeath();
  drawBird();
  moveBird();
  
}
void checkForDeath()
{
  color currentColor = get(100,(int)birdY);
  if( currentColor == #00ff00 || birdY>500 )
  {
    reset();
  }
}
void reset()
{
  println("I made it!");
  bar1X = 500;
  bar2X = 200;
  gap1Y = random(100,300);
  gap2Y = random(100,300);
  birdY = 250;
  speed = -5;
}
void drawBird()
{
  fill(#ffff00);
  ellipse(100,birdY,45,45);
}
void moveBird()
{
  if(keyPressed && key==' ')
  {
    speed = -5; 
  }
  else
  {
    speed = speed+.4;
  }
  birdY = birdY+speed;
}
void drawBars()
{
  fill(#00ff00);
  noStroke();
  rect(bar1X,0,100,500); //draws pipe
  rect(bar2X,0,100,500); //draws pipe
  
  fill(255);
  rect(bar1X,gap1Y,100,150); //draws gap
  rect(bar2X,gap2Y,100,150); //draws gap
}
void moveBars()
{
  bar1X = bar1X-3;
  if( bar1X <= -100 )
  {
    bar1X = 500;
    gap1Y = random(100,300);
  }
  
  bar2X = bar2X-3;
  if( bar2X <= -100 )
  {
    bar2X = 500;
    gap2Y = random(100,300);
  }
}