//I'm Dumping You //by Chris Kerich import java.util.Random; float breatheOut = 1; float breatheIn = -0.08; float horizScroll = -4.8; float startSpace = 30; ArrayList leftVoices = new ArrayList(); ArrayList leftXPlaces = new ArrayList(); ArrayList leftYPlaces = new ArrayList(); ArrayList rightVoices = new ArrayList(); ArrayList rightXPlaces = new ArrayList(); ArrayList rightYPlaces = new ArrayList(); int time; int leftInterval = 1000; int exhaleInterval = 1300; int inhaleInterval = 1500; int displayInterval = 1800; int textBoxHeight = 60; int drawCode = 0; stanzaGen gen = new stanzaGen(); public void setup() { //Setup background and size //SUBJECT TO CHANGE size(300, 600); background(255); fill(0); writeTitle(); time = millis(); } void delay(int delay) { int time = millis(); while(millis() - time <= delay); } public void draw() { background(255); writeTitle(); switch(drawCode) { case 0:{ leftVoice(0,breatheOut,0); rightVoice(0,breatheOut,0); if(millis() - time >= exhaleInterval) { newStanza(); time = millis(); drawCode = 1; } break; } case 1:{ leftVoice(0,breatheIn,1); rightVoice(0,breatheIn,0); if(millis() - time >= inhaleInterval) { drawCode = 2; time = millis(); } break; } case 2:{ leftVoice(0,0,0); rightVoice(0,0,0); if(millis() - time >= displayInterval) { drawCode = 0; time = millis(); } break; } case 3:{ leftVoice(horizScroll,0,0); rightVoice(horizScroll,0,0); if(millis() - time >= leftInterval) { drawCode = 0; leftVoices = new ArrayList(rightVoices); leftXPlaces = new ArrayList(rightXPlaces); leftYPlaces = new ArrayList(rightYPlaces); rightVoices = new ArrayList(); rightXPlaces = new ArrayList(); rightYPlaces = new ArrayList(); time = millis(); } break; } } } private void writeTitle() { textAlign(CENTER); text("I'm Dumping You", width/2, 15); } private void leftVoice(float horizScrolling, float vertScrolling, int range) { textAlign(LEFT); for (int i = range; i < leftVoices.size(); i++) { String s = leftVoices.get(i); Float x = leftXPlaces.get(i); Float y = leftYPlaces.get(i); x+=horizScrolling; y+=vertScrolling; if(x > 0-(width/2)) { leftXPlaces.set(i,x); leftYPlaces.set(i,y); text(s,x,y, width/2, textBoxHeight); } else { leftVoices.remove(i); leftXPlaces.remove(i); leftYPlaces.remove(i); } } } private void rightVoice(float horizScrolling, float vertScrolling, int range) { textAlign(LEFT); for (int i = range; i < rightVoices.size(); i++) { String s = rightVoices.get(i); Float x = rightXPlaces.get(i); Float y = rightYPlaces.get(i); x+=horizScrolling; y+=vertScrolling; if(y < height && x >= 0) { rightXPlaces.set(i,x); rightYPlaces.set(i,y); text(s,x,y,width/2,textBoxHeight); } else { rightVoices.remove(i); rightXPlaces.remove(i); rightYPlaces.remove(i); } } } private void newStanza() { String[] stanza = gen.genStanza(); String left = stanza[0]; String right = stanza[1]; //float space = Integer.parseInt(stanza[2]); float space = parseInt(stanza[2]); //Add Text to ArrayLists to be displayed in future draw() loops leftVoices.add(0,left); leftXPlaces.add(0,0); leftYPlaces.add(0,startSpace); rightVoices.add(0,right); rightXPlaces.add(0,width/2); rightYPlaces.add(0,startSpace+space); } private class stanzaGen { final String[] subjects = { "drop out of school", "go back to school", "get a job", "get that promotion", "change", "quit my job", "move back home", "buy a car", "stop snapping at you", "be more brave", "stop getting angry like I do", "be more caring", "resolve my intimacy issues", "let you have more free time", "be less critical", "start liking your parents", "stop texting as much", "become stronger", "become more emotionally independent", "never say those things I said ever again", "grow up", "start going to therapy", "loosen up", "return the money I borrowed", "open myself up", "move out of my parent's house", "do anything", "fix the problem" }; final String[] rightVocal = { "I'm really sorry", "I'm sorry", "I'll x", "I'll x like you always wanted", "I'll finally x", "Please, I'll x", "Please", "I know, I should x", "Would it matter if I said I'd x?", "Look, I'm sorry", "Look, I'll x", "God, I'll x", "I'll x for you", "I love you so much", "I can x" }; final String[] rightAction = { "refusal to make eye contact", "a sigh that lasts too long", "silent fidgeting", "meaningless pensiveness", "a sharp inhalation of breath", "the sound of sucking in air through teeth" }; final String[] leftVocal = { "It's too late to x", "It doesn't matter if you x", "Why didn't you x when I asked a month ago?", //"Maybe we can make this work", "It's fine", "It's okay", //"Let's try again", "I'm exhausted", "It doesn't matter", //"I still love you", "Look...no", "No", //"I want to make this work", "You can't just x", "You can't x", "I can't", //"I don't want to be doing this", "You think that if you x it will solve the problem?", "It's not just that, it's a lot of things", //"This is so hard for me to do", "It has never mattered if you x" }; final String[] leftAction = { "frustrated tears", "a pained expression", "a sad smile", "a long sigh" }; //Random rand = new Random(); public String[] genStanza() { String subject = "do that"; //First, select random right voice statement int voice = rightVocal.length; int action = rightAction.length; //int choice = rand.nextInt(voice+action); //********* Modify for web int choice = Math.floor(Math.random() * (voice+action)) + 0; String right = ""; if(choice < voice) { right = rightVocal[choice]; } else { choice = choice-voice; right = rightAction[choice]; } //See if we should pick a subject //If so, pick one if(right.indexOf(" x") != -1) { //Choose a random subject //choice = rand.nextInt(subjects.length); choice = Math.floor(Math.random() * (subjects.length)) + 0; subject = subjects[choice]; } //Pick a left voice statement voice = leftVocal.length; action = leftAction.length; //choice = rand.nextInt(voice+action); choice = Math.floor(Math.random() * (voice+action)) + 0; String left = ""; if(choice < voice) { left = leftVocal[choice]; } else { choice = choice-voice; left = leftAction[choice]; } //Substitute in the subject right = right.replaceAll(" x"," " + subject); //Change some tense forms in the subject subject = subject.replaceAll(" my ", " yo'ur "); subject = subject.replaceAll(" your ", " my "); subject = subject.replaceAll(" you ", " me "); subject = subject.replaceAll(" you", " me"); subject = subject.replaceAll(" yo'ur ", " your "); subject = subject.replaceAll(" I ", " you "); subject = subject.replaceAll(" myself ", " yourself "); //Substitute in the subject again left = left.replaceAll(" x"," " + subject); return new String[]{left,right,"60"}; } }