ArrayList particles; Attractor attractor; void setup() { size(400,400); frameRate(30); particles = new ArrayList(); attractor = new Attractor(); } void draw() { smooth(); noStroke(); background(50,50); //PARTICLES ACT MORE AS A "SCHOOL" WITH FORCES CALLED BEFORE ITERATOR //(RANDOM VALUE SET ONCE) //PVector wind = new PVector(random(-.1,.1),random(-0.3,0.1)); //PVector gravity = new PVector(0,0.1); particles.add(new Particle()); applyAttractor(attractor); //attractor.display(); //Iterator: an object that knows how to iterate Iterator it = particles.iterator(); while (it.hasNext()) { Particle p = it.next(); //PARTICLES ACT MORE INDEPENDENTLY WITH FORCES CALLED WITHIN ITERATOR PVector wind = new PVector(random(-.1,.3),random(-0.3,0.1)); PVector gravity = new PVector(0,0.1); // p.run(); //IMPLEMENT THIS FUNCTION WITH PARTICLE SYSTEM p.applyForce(wind); //p.applyForce(gravity); p.update(); p.display(); //Remove particles no longer necessary: if (p.isDead()) { it.remove(); } //Single Particle: /* particle.applyForce(wind); particle.applyForce(gravity); particle.update(); particle.display(); //particle.checkEdges(); //MOVED INTO DISPLAY */ } } void applyAttractor(Attractor a) { for (Particle p: particles) { //Syntax for calling a method external to the class //for each instance in arrayList PVector attract = a.attract(p); p.applyForce(attract); } }