
Walker a, b, c;

void setup()
{
  size(600,800);
  a=  new Walker(255,200,100);
  a.y=  100;
  b=  new Walker(200,255,200);
  b.y=  300;
  b.dx=2;
  //
  c=  new Walker(200,200,255);
  c.y=  500;
  c.dy=-1;
}
void draw()
{
  background(255);
  a.update();
  b.update();
  c.update();
}
  



class Walker
{
  //// Animated figure.
  int step=0;        // Step number.
  float x=50,y=50;
  float dx=1,dy=0;
  float w=50, h=80;
  int r=255,g=200,b=100;
  //// CONSTRUCTORS ////
  Walker( int rr, int gg, int bb)
  {
    r=rr;
    g=gg;
    b=bb;
  }
    
  //// METHODS ////
  void update()
  {
    move();
    show();
  }
  void move()
  {
    //// Take a step.
    x += dx;
    y += dy;
  }
  void show()
  {
    // Draw the body & head.
    noStroke();
    rectMode(CORNER);
    fill(r,g,b);
    rect(x,y, w, h);
    ellipseMode (CENTER );
    ellipse(x+w/2, y-20, 30,40);
    // Now, draw the legs.
    stroke(r,g,b);
    strokeWeight(12);
    if (step++ % 10 < 5)    // Check if odd or even
    {
      line(x+5,y+h, x-5,y+h+40);
      line(x+w-5,y+h, x+w-5,y+h+40);
    } else {
      line(x+5,y+h, x+5,y+h+40);
      line(x+w-5,y+h, x+w+5,y+h+40);
    }
  }
}
