xxxxxxxxxx
70
// noprotect
var words=[]; // Array of all 5 letter words
var keep=[]; // Array of 5 letter words we want to keep
var answer; // Selected word to guess
var guess; // Guess
var guesses=0; // How many guesses have been made
function preload() {
words = loadStrings('dictionary.txt');
}
function setup() {
createCanvas(500, 600);
//console.log(words.length);
answer= words[0];
x=width/2;
y=height/2;
}
function draw(){
background('skyblue');
//rect(x,y, 20, 20);
textSize(30);
text(answer, width/2, height/2);
//console.log(frameRate());
x+=1;
}
function createFile() {
let writer = createWriter('out.txt');
for(var i=0; i<keep.length; i++)
{
writer.write(keep[i]);
writer.write('\n');
}
writer.close();
}
function keyPressed()
{
console.log(keyCode);
switch(keyCode)
{
case 39: keep.push(answer);
words.splice(0,1);
answer=words[0];
break;
case 37: words.splice(0,1);
answer=words[0];
break;
case 32:
createFile();
break;
}
}