mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
update of Nature of Code examples, need to do one more before 2.0
This commit is contained in:
+5
-6
@@ -15,18 +15,18 @@ class ParticleSystem {
|
||||
float r = random(1);
|
||||
if (r < 0.5) {
|
||||
particles.add(new Particle(origin));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
particles.add(new ParticleChild(origin));
|
||||
}
|
||||
}
|
||||
|
||||
void run() {
|
||||
Iterator<Particle> it = particles.iterator();
|
||||
while (it.hasNext()) {
|
||||
Particle p = it.next();
|
||||
for (int i = particles.size()-1; i >= 0; i--) {
|
||||
Particle p = particles.get(i);
|
||||
p.run();
|
||||
if (p.isDead()) {
|
||||
it.remove();
|
||||
particles.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,3 @@ class ParticleSystem {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
ParticleSystem ps;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
size(640,360);
|
||||
ps = new ParticleSystem(new PVector(width/2,50));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user