// the story mother nature told her children String[] lines; String[] words; int j = 0; int i = 0; int a = 0; int makeline = 0; float drop_y = random(50,200); float drop_x = random(0,200); float posx = 100; float posy = 50; float backdrop = 240; PFont font; boolean makedropgo = false; PImage img2; PImage imgb; void setup() { lines = loadStrings("stmtn10.txt"); img2 = loadImage ("leaf.png"); imgb = loadImage ("tree.jpg"); size(400, 800); smooth(); background(imgb); } void draw(){ posx = random(-50,350); posy = random(-50,300); makeleaf(); if(j < lines.length){ String separators = WHITESPACE + "/<>*_;:?()\"-"; words = splitTokens(lines[j], separators); if ( i < words.length) { if(words[i].equals("I")) { pushMatrix(); translate(posx, posy); beginShape(); image(img2, 50, 50, 40, 40); endShape(); popMatrix(); } else if(words[i].startsWith("die")){ makeline += 5; drop_x = random(width); makedropgo = true; } i++; } else { i = 0; j++; } } } void makeleaf() { if (makedropgo == true) { pushMatrix(); translate(drop_x, drop_y); beginShape(); image(img2, 50, 50, 40, 40); endShape(); popMatrix(); drop_y += 90; // fill(backdrop, 100); //rect(0, 0, width, height); } if (drop_y > height) { makedropgo = false; drop_y = 50 + makeline; // background(imgb); } }