class Tree { Vector3D loc; Vector3D vel; float timer; float timerstart; float branchWidth; ArrayList a; Tree(Vector3D l, Vector3D v, float n, float w) { loc = l.copy(); vel = v.copy(); timerstart = n; timer = timerstart; branchWidth = w; a = new ArrayList(); // A branch has a starting location, a starting "velocity", and a starting "timer" Branch b = new Branch(loc,vel,timerstart,branchWidth); // Add to arraylist a.add(b); } // Move location void run() { // Let's stop when the arraylist gets too big if (a.size() < 10024) { // For every branch in the arraylist for (int i = a.size()-1; i >= 0; i--) { // Get the branch, update and draw it Branch b = (Branch) a.get(i); b.update(); b.render(); // If it's ready to split if (b.timeToBranch()) { a.remove(i); // Delete it a.add(b.branch(random(0,45))); // Add one going right a.add(b.branch(random(45,90))); // Add one going right a.add(b.branch(random(-90,45))); // Add one going left a.add(b.branch(random(-45,0))); // Add one going left } } } } }