I am modding The Powder Toy and I have created two elements.
Element one moves (and does other stuff) once per frame, and creates the other element (LITE) in the square it has just left.
I am using
parts[ID(pmap[y][x])].x += 1.0f;
to move the first element, and then
sim->create_part(-1, x, y, PT_LITE);
to make the other element (in the same code, just later on).
Obviously the LITE element is not created because the create_part() function tries to add the particle immediatly, whereas - although it happens earlier in the code - the first particle does not move out of the way until the end of the code.
Is there a function to move the first particle immediatly to make way for the second, or is there some other nifty piece of coding I could do, or are my coding methods really awful and should not be used under any circumstances?
P.S. for those interested, the code is here.
Nope, not really, you'd have to change Simulation::pmap manually. Particles (assuming there are any beside WARP) that move themselves in their update function do just that.
You should consider changing the type of the ant to a cell (with part_change_type), then looking at wherever the ant is supposed to go and spawn a new ant if there's no cell there, or change the type of the next cell to an ant if there is one. This way you could offload changing pmap to functions that usually do it (_create and _kill).
You could also make your ant an energy particle, since these are separate from non-energy particles (they don't even appear in pmap). This way you could logically separate ants and cells.
@LBPHacker (View Post)
OK, thanks. I'll give both a go.