// A class to describe a group of Flakes // An ArrayList is used to manage the list of Flakes class SnowCarol { ArrayList snowstorm; // An arraylist for all the particles PVector origin; // An origin point for where particles are born String carol[]; PVector start; SnowCarol(PVector origin, String carol[]) { snowstorm = new ArrayList(); // Initialize the arraylist for(int i=1; i < carol.length;i++) { start = origin.get(); start.y = i*16; for(int j=0; j < carol[i-1].length();j++) { snowstorm.add(new Flake(start,carol[i-1].charAt(j))); // Add "num" amount of particles to the arraylist start.x += textWidth(str(carol[i-1].charAt(j))); } } } void run() { for (int i = snowstorm.size()-1; i >= 0; i--) { Flake p = (Flake) snowstorm.get(i); p.run(); if (p.dead()) { // snowstorm.remove(i); } } } void addFlake(float x, float y, char z) { snowstorm.add(new Flake(new PVector(x,y), z)); } // A method to test if the particle system still has particles boolean dead() { if (snowstorm.isEmpty()) { return true; } else { return false; } } }