import rita.*; RiText[] rts; RiGrammar grammar; boolean hasClicked, noSwap=true; String[] images; int clicks=0; PImage b; void setup() { size(1000, 600); images = new String[5]; images[0] = "yokedtrees.jpg"; images[1] = "kitchen.jpg"; images[2]= "attic.jpg"; images[3]= "bedroom.jpg"; images[4]= "diner.jpg"; // create the grammar grammar = new RiGrammar(this, "newgrammar.txt"); RiText.setDefaultFont("Adler-24.vlw"); RiText.setDefaultColor(193,0,0); RiText.setDefaultAlignment(CENTER); rts = new RiText[13]; rts[0] = new RiText(this, "Cornell's Yoke Machine", width/2, 40); rts[1] = new RiText(this, "click to generate a room...", width/2, 70); RiText.setDefaultAlignment(LEFT); RiText.setDefaultFont("Adler-18.vlw"); rts[2] = new RiText(this, 70, 75); rts[3] = new RiText(this, 70, 100); rts[4] = new RiText(this, 70, 125); rts[5] = new RiText(this, 70, 175); rts[6] = new RiText(this, 70, 200); rts[7] = new RiText(this, 70, 225); rts[8] = new RiText(this, 70, 275); rts[9] = new RiText(this, 70, 300); rts[10] = new RiText(this, 70, 325); rts[11] = new RiText(this, 70, 375); rts[12] = new RiText(this, 70, 400); b = loadImage(images[0]); rts[0].setCallbackTimer(.2, true); } void draw() { rect(0, 0, width, height); image(b, 0, 0, width,height); } void mouseClicked() { // pick an image int index = int(random(1,images.length)); String selected = images[index]; b = loadImage(selected); // generate the text String result = grammar.expand(); String[] lines = result.split("%"); for (int i = 0; i < rts.length; i++) { rts[i].setText(lines[i].trim()); String linesFromGrammar = lines[i]; for (int j=0; j1) { noSwap = true; //we want the flipping to stop by not calling the timer } if (clicks==3) //but if we click again, we want the timer to start again { clicks = 1; //so we change the click back to as if it is 1 click hasClicked = true; //and change hasClicked back to true noSwap = false; } } void onRiTaEvent(RiTaEvent rt) { if (hasClicked && !noSwap) { String result = grammar.expand(); String[] lines = result.split("%"); for (int i = 2; i < rts.length; i++) rts[i].setText(lines[i].trim()); } }