float  SCREENSIZE = 500;
int RED  = 1;
int BLUE = 2;
int GREEN = 3;

int GANGSIZE = 100;

float INFLUENCEDIST = 20;
float ATTACKDIST = 30;

float MAXSPEED = 5;
float ATTACKSTRENGTH = 1;
float MOUSERADIUS = 20;

gang redgang, bluegang,greengang;

ArrayList gangs;

void setup(){
  size(500,500);
  frameRate(30);
  strokeWeight(2);
  gangs = new ArrayList();
  resetGangs();
}

void resetGangs(){
  redgang = new gang(RED,random(SCREENSIZE),random(SCREENSIZE));
  bluegang = new gang(GREEN,random(SCREENSIZE),random(SCREENSIZE));
  greengang = new gang(BLUE,random(SCREENSIZE),random(SCREENSIZE));

}

void keyPressed(){
  if(key == ' '){
    resetGangs();
  } 
}

void mousePressed(){
//  redgang.mouseCatch();
 // bluegang.mouseCatch();
 // bluegang.mouseCatch();
  //println("caught");
}
void mouseReleased(){
  redgang.mouseRelease();
  bluegang.mouseRelease();
  bluegang.mouseRelease();
  //println("rele");  
}

float mouseXspeed, mouseYspeed;

void draw(){
  background(200);

  mouseXspeed = mouseX - pmouseX;
  mouseYspeed = mouseX - pmouseX;

if(mousePressed){
  redgang.mouseCatch();
  bluegang.mouseCatch();
  bluegang.mouseCatch();
}

  redgang.move();
  bluegang.move();
  greengang.move();
  redgang.paintShadow();
  bluegang.paintShadow();
  greengang.paintShadow();

  redgang.paint();
  bluegang.paint();
  greengang.paint();

  redgang.attack(bluegang);
  bluegang.attack(redgang);
  greengang.attack(redgang);
  redgang.attack(greengang);
  bluegang.attack(greengang);
  greengang.attack(bluegang);

  redgang.reaper();
  bluegang.reaper();
  greengang.reaper();

}


float distance(float x1, float y1, float x2, float y2){
  float d = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
  return d; 
}

float distance(blob b1, blob b2){
  float d = sqrt(pow(b1.x-b2.x,2)+pow(b1.y-b2.y,2));
  return d; 
}