/* Curious george. Thats the red circles name.  He likes the square that tumbles around
screen and will run towards it with glee.  As it passes by he stunned and amazed by it.
Unfortunately in his blissful daze he loses sight of it and panics until he finds the
square again.  The square on the other hand is a mindless mechanical droid who only trys
to roll along in a straight line till it is disrupted by a wall.
*/
int speed, mSize, mX, mY, mSide, oCyc, oLike, oHate, oMode, tX, tY;
float mRot, oEasing, oX, oY; 

void setup(){
  size(400,400);
  smooth();
  background(255);
  speed = 10; // Must be greater than 3 and less than 45.
  mSize = 80; // evenly divided into 400 works best.
  mY = mSize;
  mX = 0;
  mSide = 0;
  oEasing = 0.01;
  oCyc = 350;
  oLike = 100;
  oHate = 200;
  oX = 200;
  oY = 200;
}

void draw(){
  background(255);
  orga();
  mach();
}

void orga(){
  int ai = frameCount%oCyc;
  if(ai < oLike){
    tX = mX;
    tY = mY;
    oMode = 0;
  }else if(ai > oHate){
    tX = 400-mX;
    tY = 400-mY;
    oMode = 1;
  }else{
    oMode = 2;
  }
  oX += (tX-oX)*oEasing;
  oY += (tY-oY)*oEasing;
  oChar(oMode);
}

void oChar(int Mode){
  noStroke();
  fill(255,0,0);
  ellipse(oX, oY, 100, 100);
  stroke(0);
  fill(255);
  ellipse(oX+21, oY-10, 40, 40);
  ellipse(oX-21, oY-10, 40, 40);
  fill(0);
  ellipse(oX+21+(tX-oX)*oEasing*5, oY-10+(tY-oY)*oEasing*5, 10, 10);
  ellipse(oX-21+(tX-oX)*oEasing*5, oY-10+(tY-oY)*oEasing*5, 10, 10);
  switch(Mode){
    case 0:
      fill(255);
      beginShape();
      vertex(oX+30, oY+15);
      bezierVertex(oX+30, oY+45, oX-30, oY+45, oX-30, oY+15);
      vertex(oX+30, oY+15);
      endShape();
      break;
    case 1:
      fill(64, 0, 0);
      beginShape();
      vertex(oX+20, oY+30);
      bezierVertex(oX+20, oY, oX-20, oY, oX-20, oY+30);
      vertex(oX+20, oY+30);
      endShape();
      break;
    case 2:
      fill(0);
      ellipse(oX, oY+30, 10, 10);
      break;
  }
}

void mChar(){
  stroke(0);
  fill(128);
  rect(0,0,mSize,mSize);
}

void mach(){
  switch(mSide%4){
    case 0:
      pushMatrix();
      translate(mX, mY);
      mRot = radians((frameCount*speed)%360)/4-PI/2;
      rotate(mRot);
      mChar();
      popMatrix();
      if((((frameCount-3)*speed)/4)%90 == 90-speed){
        mY += mSize;
        if(mY >= height){
        mSide ++;
        mX += mSize;
        }
      }
      break;
    case 1:
      pushMatrix();
      translate(mX, mY);
      mRot = radians((frameCount*speed)%360)/4-PI;
      rotate(mRot);
      mChar();
      popMatrix();
      if((((frameCount-3)*speed)/4)%90 == 90-speed){
        mX += mSize;
        if(mX >= width){
        mSide ++;
        mY -= mSize;
        }
      }
      break;
    case 2:
      pushMatrix();
      translate(mX, mY);
      mRot = radians((frameCount*speed)%360)/4+PI/2;
      rotate(mRot);
      mChar();
      popMatrix();
      if((((frameCount-3)*speed)/4)%90 == 90-speed){
        mY -= mSize;
        if(mY <= 0){
        mSide ++;
        mX -= mSize;
        }
      }
      break;
    case 3:
      pushMatrix();
      translate(mX, mY);
      mRot = radians((frameCount*speed)%360)/4;
      rotate(mRot);
      mChar();
      popMatrix();
      if((((frameCount-3)*speed)/4)%90 == 90-speed){
        mX -= mSize;
        if(mX <= 0){
        mSide ++;
        mY += mSize;
        }
      }
      break;
  }
}
Exercise 10: Animate two shapes of your own design. Give one a mechanical motion and give the other a more organic motion.