//// Button

boolean day=true;
float buttonX=200, buttonY=200;
float buttonW=80, buttonH=30;

void setup() { size( 600, 400 ); }

void draw() {
  scene();
  button();
  gossip();
}

void scene() {
  if (day) {
    background( 200, 220, 255 );  // day sky
  } else {
    background( 120, 150, 180 );  // nite
  }
  fill( 200, 255, 200 );
  rect( 0,height/4, width, height*3/4 );    // grass;
}

void button() {
  fill(255,200,200);
  rect( buttonX,buttonY, buttonW,buttonH );
  fill(0);
  textSize(12);
  text( "Click here", buttonX+10, buttonY+20 );
}

void gossip() {
  textSize(24);
  text( "Button test", 10, 20 );
  textSize(12);
  text( "B.A.Martin", 10, height-10 );
}

//// EVENT HANDLERS ////
void keyPressed() {
  if (key == 'q') { exit(); }
  if (key == 'd') {
          day = ! day;
  }
}
void mousePressed() {
  // Change day/nite if click inside button
  if ( mouseX > buttonX
    && mouseX < buttonX+buttonW
    && mouseY > buttonY
    && mouseY < buttonY+buttonH ) {
      /*
      if (day ) { day = false; }
      else { day = false; }
      */
      day = ! day;
    }
}



