// NounVerber // Dave Bollinger, Jan 2006 // http://www.davebollinger.com // updated for Processing 0109 Beta /** Click mouse to generate next title...
't' toggles letter color tinting on/off
*/ ScreenFader fader; StarField starfield; CoinSlot coinslot; FlyingTitle title; String [] nounList; String [] verbList; boolean bColorTint = true; void setup() { size(224,288); background(#000033); fader = new ScreenFader(0,0,51,32); starfield = new StarField(1000); coinslot = new CoinSlot("coinslot.gif"); BitmapFont font = new BitmapFont("envyfont.gif", 26, 'A', 32, 24); title = new FlyingTitle(font, "NOUN", "VERBER"); nounList = loadStrings("nounlist.txt"); verbList = loadStrings("verblist.txt"); } void draw() { fader.draw(); starfield.draw(); coinslot.draw(); title.draw(bColorTint); } void keyPressed() { if (key=='`') saveFrame("frame.tga"); if (key=='t') bColorTint=!bColorTint; } void mousePressed() { String noun = nounList[(int)random(nounList.length)].toUpperCase(); String verber = verbList[(int)random(verbList.length)].toUpperCase(); title.create(noun, verber); } /* * ScreenFader - handles clearing the screen */ class ScreenFader { color c; ScreenFader(int r, int g, int b, int a) { c = color(r,g,b,a); } void draw() { fill(c); noStroke(); rect(0,0,width,height); } } /* * FlyingTitle - manages the collection of FlyingLetter's */ class FlyingTitle { static final int nletters = 10; FlyingLetter [] letters; int currentHue = 0; FlyingTitle(BitmapFont font, String noun, String verber) { letters = new FlyingLetter[nletters]; for (int i=0; i 0.0) t -= 0.02; if (t < 0.0) t = 0.0; int x = targetx - (int)(t * dx); int y = targety - (int)(t * dy); font.draw(letter, x, y); } } /* * BitmapFont - manages images of bitmap characters */ class BitmapFont { PImage [] images; int nchars, firstchar; BitmapFont(String filename, int n, int f, int w, int h) { nchars = n; firstchar = f; images = new PImage[nchars]; PImage temp = loadImage(filename); for (int i=0; i=0) && (i=width) || (sy>=height)) { create(); } else { fill((int)((1.0-z/maxz)*255.0)); rect(sx,sy,1,1); } } }