import java.awt.*; public class basicletter { protected char letter; protected Color color; protected int x, y, v; //creates new letter at coordinates (newx, newy) with letter newletter and makes a random color public basicletter(char newletter, int newx, int newy) { letter = newletter; x = newx; y = newy; v=0; int r=0, g=0, b=0; while (r == 0 && g == 0 && b == 0) //while the color isn't black { r = (int)(Math.random()*2); //pick whether to have that color, I only have two g = (int)(Math.random()*2); //options for each color so they will be bright b = (int)(Math.random()*2); //and obviously different colors } color = new Color(r*255, g*255, b*255); } //draw the new letter at it's current coordinate public void draw(Graphics g) { g.setColor(color); g.drawString(new String("") + letter, x, y); } //change the location of the letter by 'v', the virtual velocity public void update() { y+=(int)v; v+=1; //constant acceleration simulated here so it looks like it's falling if (y>=300) //if the letter is at the bottom of the window, make it bounce. v=-9*v/10; } }