PImage back; ArrayList particles; void setup() { size(300,300); back = loadImage("back_arraylist.gif"); framerate(40); stroke(1); colorMode(RGB,200,200,200,90); particles = new ArrayList(); smooth(); } void draw() { particles.add(new Particle()); image(back,0,0); // iterate through our arraylist adn get each particle for (int i = 0; i < particles.size(); i++) { // when something comes out of the arraylist via "get" we have to // remind ourselves what type it is. In this case, it's an instance of "Particle" Particle p = (Particle) particles.get(i++); p.run(); p.gravity(); p.render(); } // Remove the first particle when the list gets over 100. if (particles.size() > 100) { particles.remove(0); } } class Particle { float x; float y; float xspeed; float yspeed; Particle() { x = mouseX; y = mouseY; xspeed = random(-1,5); yspeed = random(-5,1); } void run() { x = x + xspeed; y = y + yspeed; } void gravity() { yspeed += 0.5; } void render() { fill(200,40); noStroke(); ellipse(x,y,random(60),random(30)); } }