nick /224 /blobs

friend[] f = new friend[50];

void setup(){
  size(800,600);
  //f1 = new friend();
  for(int i = 0; i < f.length; i++){
    f[i] = new friend();
  }
  background(255);
}

void draw(){
  for(int i = 0; i < f.length; i++){
    f[i].move();
    f[i].draw();
  }

}

class friend{
  int x, y;
  int vx, vy;
  int r, g, b, a;
  friend(){
    x = (int)random(width);
    y = (int)random(height);
    randomize();
    r = (int)random(0,255);
    g = (int)random(0,255);
    b = (int)random(0,255);
    a = (int)random(0,255);
  }
  void move(){
    //x+= vx;
    //y+= vy;
    if(x + vx<= 0 || x + vx >= width){
      vx = -vx;
    }
    if(y + vy <= 0 || y + vy >= height){
      vy = -vy;
    }
    color cp = get(x + vx,y);
    float s = saturation(cp);
    float b = brightness(cp);
    if((s == 0) && (b == 255)){
      x += vx;
    }
    else {
      vx = -vx;
    }
    cp = get(x,y + vy);
    s = saturation(cp);
    b = brightness(cp);
    if((s == 0) && (b == 255)){
      y+= vy;
    }
    else {
      vy = -vy;
    }
    cp = get(x + vx,y + vy);
    s = saturation(cp);
    b = brightness(cp);
    if((s == 0) && (b == 255)){


    } else {
      x = (int)random(width);
      y = (int)random(height);
      r = (int)random(0,255);
      g = (int)random(0,255);
      b = (int)random(0,255);
      a = (int)random(0,255);
    }
    //x += vx;
    //y += vy;
  }
  void draw(){
    stroke(r,g,b,a);
    point(x,y);
  }
  void randomize(){
    float coin = random(10);
    if(coin < 5)
      vx = 1;
    else
      vx = -1;
    coin = random(10);
    if(coin < 5)
      vy = 1;
    else
      vy = -1;
  }


}




Page Details
Contact DANM  |  Digital Arts and New Media  |  Arts Division  |  Grad Division
login