class Particle { float ox, oy; // original position float x, y; // current position float vx, vy; // velocity float t; // tint float dt = 3; // tint step PImage img; Particle(float x0, float y0, PImage img) { ox = x0; oy = y0; this.img = img; // distinguish parameter from field initialize(); } // Put at original position, fully opaque, with random velocity void initialize() { x = ox; y = oy; t = 255; // Mostly vertical vx = (float)generator.nextGaussian()*0.3; vy = (float)generator.nextGaussian()*0.3 - 1; } void draw() { imageMode(CORNER); tint(255,t); image(img, x-img.width/2, y-img.height/2); } void update(float wind) { t -= dt; // decay the transparency x += vx+wind; y += vy; // Re-initialize when decayed away if (t < 0) initialize(); } }