We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › draw () confusion...
Page Index Toggle Pages: 1
draw () confusion... (Read 261 times)
draw () confusion...
Mar 19th, 2008, 9:46pm
 
I have been playing arround with the simpleParticleEmitter example in processing. I changed the behaviour of the particles so that they react depending on how the other particles are distributed over the screen.

The problem I have is that only that particle furthest away from a certain point should move.

p = particle
change = function returning a movement Vector

void run() {
   float max_dist = 0.00;
   for (int i = particles.size()-1; i >0; i--) {
     Particle p = (Particle) particles.get(i);
     if (p.p_dist > max_dist) {max_dist = p.p_dist;}
   }

   particles_cou = 0;
   for (int i = 0;particles.size() > i; i++) {
     Particle p = (Particle) particles.get(i);
     if (p.p_dist >= max_dist) {p.run(change(p));}
   }
 }

this gets called from draw()

void draw() {
 ps.run();
}

When executing this code it doesn't always start with the furthest away. when I increase the frame rate the mistake gets worse.

Doesn't the draw function wait until the run part is completely executed ?


tHX for the Help

Richard


Re: draw () confusion...
Reply #1 - Mar 20th, 2008, 9:31am
 
There was a post some days before with the same problem: don't name your fucntion run() cause it's use by processing.
Page Index Toggle Pages: 1