add "void* data" to particle definition add the following struct
struct particle_connection { int other; particle* pointer; float dist; float spring; //normally 0.1 when the particles are created and at other times (like when metal unmelts), do this
or something like this anyways. variables, functions and C syntax (no C++ or Java) may need to be fixed.
//this is run whenever the particle needs to have some bonding time with other particles //oh it should prolly check when these particles are gonna die, shouldn't it //otherwise major glitching... crap I can't think of a way to detect that. parts[i].data=new particle_connection[8]; int numd=0; for(int x=rx-1;xfor(int y=ry-1;yif(0particle p=partmap[x][y]; if(/*can connect to this, maybe check types*/){ particle_connection& newpc=(particle_connection*)parts[i].data+numd*12 /*is that necessary or does C multiply pointer offsets by type size?*/ newpc.other=p.number; newpc.pointer=&newpc; newpc.spring=0.3; //or some other number depending on the material newpc.dist=//distance between myself and the other particle } }
//this is run whenever the particle is calculating its physics int numpc=0; particle_connection pclist[]=parts[i].data; particle cp=pclist[numpc]; while(numpc<8){<br />if(cp.pointer==null){ numpc=8; } else { if(YOUR PARTICLE GOT PWNED BY VOID OR SOMETHING){ int tnumpc=numpc; while(tnumpc<7)<br />pclist[tnumpc]=pclist[tnumpc+1]; pclist[7].other=0; pclist[7].pointer=0; pclist[7].dist=0.0; pclist[7].spring=0.0; } else { float dx=cp.x-x; float dy=cp.y-y; float dd=cp.spring*(sqrt(dx*dx+dy*dy)/cp.dist-1.0) vx+=dd*dx; vy+=dd*dy; numpc++; cp=pclist[numpc]; } } }
... yes I am a programmer no I do not eat girl scout cookies.
Yeah. Plus as n00b as it sounds, I think on the inside we all would be happy if we could have movable solids. I think the repeated requests have made us agitated at the mention of them, but the idea itself is quite nice:)