creature rawr; void setup() { size(500,500); ellipseMode(CENTER_DIAMETER); rawr=new creature(); // rawr.debug(); } void loop() { background(105); renderCreature(rawr); // rawr.update(); // rawr.draw(); } void mouseReleased() { setup(); } void renderCreature(creature c) { position central=c.centralCell.posGlobal; //draw central axis stroke(190,190,190); line(central.x,150,central.x,height-150); line(central.x-30,central.y,central.x+30,central.y); //draw central cell noStroke(); fill(130,205,195); ellipse(central.x,central.y,6,6); //draw cells for(int i=0;i0) // { if(s.y>testY) return 1; else return -1; /* } else { if(s.y>testY) return -1; else return 1; }*/ } } position displace(position p,float angle,float magnitude) //displaces a position by an angle and a magnitude, then returns it { position newP=new position(p); float ra=radians(angle); newP.x+=(cos(ra)*magnitude); newP.y-=(sin(ra)*magnitude); return newP; } float getHeading(position p1,position p2) //gets the absolute heading between one position and another relative to the first { if(p1.x==p2.x&&p1.y==p2.y) return 0; float xd=p2.x-p1.x; float yd=p2.y-p1.y; float angle=float(Math.atan(yd/xd)); // angle=degrees(angle); angle=angle*conversionArc; if(xd>0&&yd<0) { angle=-1*angle; } else if(xd<0&&yd<0) angle=180-angle; else if(xd<0&&yd>0) angle=180-angle; else if(xd<0&&yd==0) angle=180; else if(xd==0&&yd<0) angle=90; else angle=360-angle; return angle; } float dist(position p1,position p2) { return dist(p1.x,p1.y,p2.x,p2.y); } float normalizeHeading(float ang) //normalizes a heading between 0 and 360 { while(ang > 360)ang -= 360; while(ang < 0)ang += 360; return ang; } void drawVector(vector v) //draws a vector in white { colorMode(RGB,255,255,255); stroke(255); noFill(); ellipseMode(CENTER_DIAMETER); ellipse(v.p.x,v.p.y,5,5); position e=v.endPoint(); line(v.p.x,v.p.y,e.x,e.y); } void drawVector(vector v,float s) //draws a vector with a longer line for representation in white { colorMode(RGB,255,255,255); stroke(255); noFill(); ellipseMode(CENTER_DIAMETER); ellipse(v.p.x,v.p.y,5,5); vector temp=new vector(v); temp.m*=s; position e=temp.endPoint(); line(temp.p.x,temp.p.y,e.x,e.y); } void drawVector(vector v,int r,int g,int b,float s) //draws a vector with a longer line for representation in white { colorMode(RGB,255,255,255); stroke(r,g,b); noFill(); ellipseMode(CENTER_DIAMETER); ellipse(v.p.x,v.p.y,5,5); vector temp=new vector(v); temp.m*=s; position e=temp.endPoint(); line(temp.p.x,temp.p.y,e.x,e.y); } void drawVector(vector v,int r,int g,int b) //draws a vector in RGB { colorMode(RGB,255,255,255); stroke(r,g,b); noFill(); ellipseMode(CENTER_DIAMETER); ellipse(v.p.x,v.p.y,5,5); position e=v.endPoint(); line(v.p.x,v.p.y,e.x,e.y); }