Skip to content

Instantly share code, notes, and snippets.

@fartagaintuxedo
Created June 2, 2013 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fartagaintuxedo/5693387 to your computer and use it in GitHub Desktop.
Save fartagaintuxedo/5693387 to your computer and use it in GitHub Desktop.
int numpers=40;
Persona[] listpers=new Persona[numpers];
void setup(){
size(500,500);
String[] nombresCH={"qing","gao","huang","li","qiong","bruce","lee", "wang", "xu", "sheng","wen", "zhu", "hong"};
String[] nombresES={"alejandra", "fatima", "eugenia", "marta", "ana", "maria", "carmen", "lucia","sandra"};
for(int i=0;i<listpers.length;i++){
PVector l=new PVector(random(0,width),random(0,height));
PVector v=new PVector(random(-1,1),random(-1,1));
String nombre=nombresES[int(random(0,nombresES.length))]+" "+nombresCH[int(random(0,nombresCH.length))];
listpers[i]=new Persona(l,v,nombre,random(-10,10),random(-10,10),"sexo1");
}
}
void draw(){
background(0);
for(int i=0;i<listpers.length;i++){
Persona p=listpers[i];
p.walk();
p.buitre();
p.render();
p.bordes();
}
}
class Persona {
PVector loc;
PVector vel;
String nombre;
float belleza;
float simpatia;
String sexo;
Persona( PVector _loc, PVector _vel,
String _nombre, float _belleza, float _simpatia, String _sexo){
loc=_loc;
vel=_vel;
nombre=_nombre;
belleza=_belleza;
simpatia=_simpatia;
sexo=_sexo;
}
void buitre(){
for(int i=0;i<listpers.length;i++){
Persona p=listpers[i];
if((p.loc.x-loc.x<50 && -p.loc.x+loc.x<50) && (p.loc.y-loc.y<50 && -p.loc.y+loc.y<50)){
PVector d=PVector.sub(p.loc,loc);
d.normalize();
d.mult((p.belleza + p.simpatia)/10);
if (d.mag()>0){
loc.add(d);
strokeWeight(0.5);
stroke(255,0,0);
line(loc.x,loc.y,p.loc.x,p.loc.y);
}
}
}
}
void walk(){
loc.add(vel);
}
void render(){
ellipse(loc.x,loc.y,4,4);
}
void bordes(){
if(loc.x>width){
loc.x=0;
}
if(loc.x<0){
loc.x=width;
}
if(loc.y>height){
loc.y=0;
}
if(loc.y<0){
loc.y=height;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment