Psychoticpigeonn
YaBB Newbies
Offline
Posts: 6
Acrostic issues
Feb 17th , 2008, 5:07pm
I'm new to processing and I am trying to make an acrostic. The issues I am having are: A. hitting the backspace isn't visibly remove the letter. B. I can't figure out how to create a text field for each letter. I can create static fields but I can't get it to generate a field for each letter in the word. I am not sure what I am doing wrong. here's my code: void setup() { size(640,530); colorMode(RGB, 255, 255, 255); background(0, 0, 25); //loads the font PFont font; font = loadFont("Andalus-48.vlw"); textFont (font, 48); //loads the data from the text file and //coverts it into an array. String words[] = loadStrings("wordlist.txt"); //displays a random word from the array float y = random(words.length-1); int x = round(y); text (words[x], 250, 50); //splits the word into the letters then displays them vertically String letters[] = splitTokens(words[x], " "); int i= 0; int Height = (400/letters.length); for (int c=0; c < letters.length; c++) { i++; int Height2 = Height * i; text (letters[i-1], 100, (Height2 + 40)); } } String typed = ""; //copied from the book. this displays the string that is //being edited by my typing. I think it is rendering a new //object each time I press a button instead of rerendering //the current one. void draw() { float cursorPosition = textWidth(typed); line(cursorPosition, 100, cursorPosition, 100); text(typed, 0, 50); } void keyPressed() { if (key == BACKSPACE) { if (typed.length() > 0) { typed = typed.substring(0, typed.length()-1); } } else if (textWidth(typed+key) < width){ typed = typed+key; } }