class cell { position p; vector velocity; float velocityDamping=0.01; // float mass; connection c; gene g; neuron n; float resistance; boolean isNeuron=false; //cells tagged with this marker is capable of giving output signals boolean isMuscle=false; //cells tagged with this marker is capable of varying spring distances cell(position pt) { p=new position(pt); velocity=new vector(p,0,0); c=new connection(); } void update() { doDrag(); doFriction(); if(useGravity) doGravity(); doVelocity(); // doBorders(); } void doGravity() { velocity=velocity.add(GRAVITY_VECTOR); } void doDrag() { boolean neg=false; if(velocity.m<0) neg=true; resistance=sqrt(velocity.m); resistance*=FLUID_FORCE; if(resistance<0.1) resistance=0; resistance+=1; // if(neg) // resistance*=-1; } void doFriction() { velocity.m*=FRICTION_FORCE; velocity.m*=1-velocityDamping; } void doVelocity() { p=p.displace(velocity); } void doBorders() { boolean collide=false; if(p.x<10) { p.x=10; collide=true; } else if(p.x>width-10) { p.x=width-10; collide=true; } if(p.y<120) { p.y=120; collide=true; } else if(p.y>height-50) { p.y=height-50; collide=true; } if(collide) velocity.m*=.7; } float x() { return p.x; } float y() { return p.y; } }