/* DickensDrinking * by Erica Liszewski * on November 18, 2007 * for DMST3211 * * DickensDrinking is a visualization of how much alchohol one would * consume by playing the Dickens Drinking Game in real life. The Game * is played by reading a Dickens novel ( 5 selections are provided ) * and taking a drink when one comes accross * the words "ale", "wine", "gin", or "beer". One should, in theory, * have a container of each of these liqours on hand, and drink to the * appropriate one, but I have not yet implemented this feature. * * Users can select the story they'd like to see from the buttons on * the right. */ //for separating out words String separators = WHITESPACE + "/<>*_,:.;?!()\"-"; //setup for books and titles String[] titles = {"Little Dorrit", "David Copperfield", "Oliver Twist", "The Tale of Two Cities", "Great Expectations"}; String[] files = {"LittleDorrit", "DavidCopperfield", "OliverTwist", "TaleOfTwoCities", "GreatExpectations" }; WineManager wine;//manages the wine int line_count;//keeps track of what line we're on String[] lines = {"Please Choose a Story"};//contains the novels String title = "";//the title of the current novel PFont font;//for displaying text String chapter = "Please Choose a Story";//the chapter text at the top float framerate;//framerate is variable TitleButton[] buttons;//contains the buttons void setup(){ size(600, 450); wine = new WineManager(width-100, height-40, 0, 70); framerate = 5; frameRate(framerate); background(255); line_count = 0; font = loadFont("AmericanTypewriter-Condensed-20.vlw"); textFont(font); setupButtons(); } void draw(){ background(255); //clear boolean chapter_end = false; //we are starting a chapter /* used for a slightly different visualization */ // if(line_count < lines.length){ //loop through lines until the end of a chapter while(line_count < lines.length && !chapter_end){ //split the words out of each line String[] words = splitTokens(lines[line_count], separators); //setup for drawing text fill(0); /* used for a slightly differnt visualization */ // text(lines[line_count], 5, 57); //for each word for(int i=0; i< words.length; i++){ //lowercase and remove any remaining whitespace String word = (words[i].trim()).toLowerCase(); //if we find some sort of alcohol, "sip" the wine if(word.equals("wine")){ wine.sip(); } else if(word.equals("gin")){ wine.sip(); } else if(word.equals("ale")){ wine.sip(); } else if(word.equals("beer")){ wine.sip(); //if we find chapter, we're starting the next chapter }else if(words[i].equals("CHAPTER")){ if(i+1 < words.length) chapter = words[i] + " " + words[i+1]; chapter_end = true; } } line_count++; //increment line } //render the text at the top fill(0); textFont(font); textSize(20); text("Dickens Drinking Game, "+title, 5, 21); textFont(font); textSize(18); text(chapter, 5, 41); //render the wine wine.render(); //render the buttons for(int i=0; iwidth-100){ for(int i=0; ithis.y && y< this.y+my_height) return true; else return false; } }