// head & shoulders  2a
float horizon;
float zoogX, zoogY, zoogDX=2, zoogDY=1;

void setup() {
  size( 800, 600 );
  horizon=  height/4;
  reset();  
}
void reset() {
  zoogX=  width/4;  
  zoogY=  height/3;
}
void draw() {
  scene();
  action();
  messages();
}
void action() {
  // Move Zoog
  if (zoogX>width-80 || zoogX<10) { zoogDX=  -zoogDX; }
  if (zoogY>height-120 || zoogY<horizon) { zoogDY=  -zoogDY; }
  zoogX = zoogX + zoogDX;
  zoogY = zoogY + zoogDY;

  // Draw Zoog:
  showZoog( zoogX, zoogY );
}

void showZoog( float x, float y ) {  
  float d=40, w=50, h=80;
  fill( 255,200,100 );          // Orange
  ellipse( x,y, d,d );          // head  

  // Eyes
  // Animation (2-part)
  float shift;
  if (zoogDX>0) shift=  3;
  else shift=  -3;
  eye( x-8, y-8, shift );
  eye( x+8, y-8, shift );
  
  // Coordinates of shoulder:
  float xx=  x - w/2;          // Left side of shoulder.
  float yy=  y + d/2;          // Top of shoulder.
  fill( 255, 255, 0 );
  rect( xx, yy, w, h );        // Body
  fill(0);
  textSize(16);
  text( "Zoog", xx+5, yy+20 );    // Name on shirt

  //  Arrow on shirt (points right or left).
  String arrow="-->";
  color c=color(0,0,255);
  if (shift<0) {
    arrow="<==";
    c=  color(255,0,0);
  }
  fill(c);
  text( arrow, xx+5, yy+40 );    // Arrow on shirt  
}
void eye( float x, float y, float shift ) {
  fill( 255 );                  // White
  ellipse( x,y, 12,12 );
  fill( 0,0,255 );              // Blue
  ellipse( x+shift,y, 5,5 );
}

void messages() {
  // +++
}

void scene() {
  background(200, 220, 250);
  fill( 200, 255, 220 );
  rect( 0, horizon, width, height );
}
