//// Dynamic sketch - modularized.
//// B.A.Martin: '8912

int width=600, height=400; 
float horizon;
float zoogX, zoogY;
float sunX=10, sunY=50;


//// SETUP:  size & modes
void setup() {
    size( width, height ); 
    horizon=  height/3;
}

//// NEXT FRAME:  scene, action, show
void draw() {
    background( 150,200,250 );      // sky
    scene();
    action();
    show();
}

/// Scene:  sky & grass
void scene() {
    fill( 100,255,100 );
    rect( 0,horizon, width,height-horizon );  // grass
    fill( 255,255,0 );
    ellipse( sunX,sunY, 30,30 );
    fill( 255,0,0 );
    rect( 200,horizon-80, 100,80 );  // house
    fill(0);
    rect(  220,horizon-60, 30,60 );    // door
    //
    text( "Click to reset the sun!", width/2,30 );
}

//// Action:  Make Zoog follow the mouse; sun moves across.
void action() {
      zoogX=  mouseX;
      zoogY=  mouseY;  
      sunX =  sunX + 1;    // Sun moves across sky.
}

//// Show:  draw Zoog.
void show() {
    fill( 255,0,255 );
    ellipse( zoogX,zoogY, 16,20 );
    fill( 0,0,255 );
    rect( zoogX-15,zoogY+10, 30,40 );
}




//// Click:  reset the sun!
void mousePressed() {
  sunX=10;
}

