/** Falling letters by Guru
press any key to drop them again */ PFont font; float[] posx; float[] velx; float[] massx; char[] letter = new char[]{'H','E','L','L','O'}; void setup() { size(300,300); font = loadFont("Verdana-48.vlw"); textFont( font, 48 ); posx = new float[] {0,0,0,0,0}; velx = new float[] {0,0,0,0,0}; massx = new float[] {random(10)+1,random(10)+1,random(10)+1,random(10)+1,random(10)+1}; } void draw() { for(int i =0; i < 5; i++) { if ( posx[i] + velx[i] > 300 ) { posx[i] = 300; velx[i] = -velx[i] * 0.5; } else { posx[i] += velx[i]; } velx[i] += 10 / massx[i]; } background(0); fill(255); for( int i=0; i < 5; i++ ) { pushMatrix(); float y = map( i, 0,4, -60,60); translate( width/2 + y, posx[i]); text(letter[i], 0, 0 ); popMatrix(); } } void keyPressed() { posx = new float[] {0,0,0,0,0}; velx = new float[] {0,0,0,0,0}; massx = new float[] {random(10)+1,random(10)+1,random(10)+1,random(10)+1,random(10)+1}; }