//A structure and motion study for a complex cellular automata //by Alessandro Capozzo -GHOSTAGENCY- // 4th december 2003 //built with proce55ing alpha .67 //______________________________________________________________ //creature data, setting for 1 worm with 14 nodes Structure [] list; int num=14; int countList=1; void setup() { size(640,320); framerate(40); list=new Structure[countList]; for(int index=0;index550)&&(dirX>0)){ dirX=-5; checkX=true; } if((posy<50)&&(dirY<0)){ dirY=5; checkY=false; } if((posy>550)&&(dirY>0)){ dirY=-5; checkY=false; } if(dirX!=xSpeed){ xSpeed+=((dirX-xSpeed)*.12f); } if(dirY!=ySpeed){ ySpeed+=((dirY-ySpeed)*.12f); } if(angx>=TWO_PI){ angx=0.00f; } angx+=coef; if(angy>=TWO_PI){ angy=0.00f; } angy+=coef; posx+=(int)(xSpeed+(xSpeed*sin(angx))); posy+=(int)(ySpeed+(ySpeed*sin(-angx))); bx=posx; by=posy; node(); } } void distance(){ objX=cont[me-1].bx-bx; objY=cont[me-1].by-by; dist=sqrt(sq(objX)+sq(objY)); if(abs(dist)!=30){ objY+=.01f; objX+=.01f; beta=(float)(Math.atan(objY/objX)); if(cont[me-1].by>=by){ radius=30; }else { radius=-30; } if(beta>0){ bx=cont[me-1].bx-(int)((radius)*cos(beta)); by=cont[me-1].by-(int)((radius)*sin(beta)); }else { bx=cont[me-1].bx+(int)((radius)*cos(beta)); by=cont[me-1].by+(int)((radius)*sin(beta)); } tarX=cont[me-1].bx; tarY=cont[me-1].by; //render objects stroke(180,190,110); line(tarX,tarY,bx,by); node(); if(me==1){ //head skin(tarX,tarY,20,0); int lung=20; int alt=20; for (int hd=1; hd<5; hd++){ lung= (int)(lung*.9f); alt=(int)(alt*.4f); skin(tarX,tarY,20-alt,lung); } }else if (me==(nBall-1)) { //tail skin(tarX,tarY,20,0); skin(bx,by,20,0); int lung=-20; int alt=20; for (int hd=1; hd<5; hd++){ lung=(int)(lung*.9f); alt=(int)(alt*.4f); skin(bx,by,20-alt,lung); } } else { skin(tarX,tarY,20,0); } } } void node(){ stroke(210,220,130); fill(236,99,41); ellipseMode(CENTER_DIAMETER); ellipse(bx,by,10,10); } void skin(int skinX,int skinY,int diam,int sposta){ push(); for(int i=1;i<5;i++){ push(); translate(skinX,skinY); float nbeta = atan2(objY,objX); rotateZ(nbeta); push(); int q=8; float d= 0.0f; while(d < TWO_PI) { rotateX(TWO_PI/q); push(); for (int ic=0;ic