int bar1X = 500;
int bar2X = 800;
float gap1Y = random(0,500);
float gap2Y = random(0,500);
float birdY = 250;
float birdSpeed = 3;
void setup()
{
  size(500,500);
}
void draw()
{
  background(255);
  drawBars();
  moveBars();
  drawBird();
  moveBird();
  checkForDeath();
}
void checkForDeath()
{
  if( get(118,(int)birdY) == #09ff09 )
  {
    reset();
  }
}
void reset()
{
  bar1X = 500;
  bar2X = 800;
  gap1Y = random(0,500);
  gap2Y = random(0,500);
  birdY = 250;
}
void moveBird()
{
  if( mousePressed )
  {
    birdSpeed = -3;
  }
  else
  {
    birdSpeed = birdSpeed + .3;
  }
  birdY = birdY+birdSpeed;
  println(birdSpeed);
}
void drawBird()
{
  fill(#FFFF00);
  ellipse(100,birdY,30,30);
}
void drawBars()
{
  fill(#09ff09);
  noStroke();
  rect(bar1X,0,100,500); //pipe
  rect(bar2X,0,100,500); //pipe
  
  fill(255);
  rect(bar1X,gap1Y,100,100); //gaps
  rect(bar2X,gap2Y,100,100); //gaps
}
void moveBars()
{
  bar1X = bar1X-2;
  if( bar1X <= -100)
  {
    bar1X = 500;
    gap1Y = random(0,500);
  }

  bar2X = bar2X-2;
  if( bar2X <= -100)
  {
    bar2X = 500;
    gap2Y = random(0,500);
  }
}