Hi, I did a code with a text input and an example external file ("list.txt", that contains few words: arancia, banana, MELA, melanzane).
At the moment if you type "red", the background color changes for a while. But I'd like to write a code where if the last typed word is equals to one of the word in the external file, then the background color changes. (it should be a sort of finder)
How could I do it?
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioOutput out;
WhiteNoise wn;
int resultIndex = 0;
int leftmargin = 10;
int rightmargin = 20;
String buff = "";
String words;
String ultimaParola;
boolean didntTypeYet = true;
void setup() {
size(640, 360, P3D);
//GENERATE WHITE NOISE//
minim = new Minim(this);
out = minim.getLineOut();
wn = new WhiteNoise(0.7); // makes a WhiteNoise signal with an amplitude of 0.2
out.addSignal(wn); // adds the signal to the output
//TEXT INPUT//
textFont(loadFont("Univers45.vlw"), 25);
String[] vocabulary = loadStrings("list.txt");
vocabulary = loadStrings ("list.txt"); // Search words
String [] lines = loadStrings("list.txt");
words = join(lines, "\n").toLowerCase();
// println(words);
String [] list = split(words, '\n');
// println(list[2]);
}
void draw()
{
fill(0);
background(255);
text(buff, 10, height/2);
}
void keyPressed() {
char k;
k = (char)key;
// println(int(key));
switch(k) {
case 8:
if (buff.length()>0) {
buff = buff.substring(0, buff.length()-1);
}
break;
/* case 13: // Avoid special keys
case 10:
// buff+="\n";
break;
case 65535:
case 127:*/
case 27:
break;
default:
didntTypeYet = false;
buff+=k;
println(buff);
String[] parole =splitTokens(buff);
if (parole!=null) {
String ultimaParola=parole[parole.length-1];
ultimaParola = ultimaParola.toLowerCase(); //Tutte le lettere diventano minuscole;