Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
Exercises:
1. Change the nouns, verbs, adverbs to your own choice of words
2. Change the sentence structure (for example, add "and" and then a second clause)
3. Change the words to a different language (could be the one you are studying in
school right now). Change the sentence structure so that the sentences are grammatically
correct.
*/
var nouns, verbs, adverbs;
function setup() {
createCanvas(500, 500);
textSize(20);
nouns = ["cat", "dream", "computer"];
verbs = ["eats", "sleeps", "paints"];
adverbs = ["cheerfully", "uneasily", "abruptly"];
//list all the verbs (example of how to loop through the array)
for(var i=0;i<verbs.length;i++) {
console.log(verbs[i]);
}
//make a random sentence and draw it to the screen
var sentence = "The ";
sentence += nouns[floor(random(nouns.length))] + " ";
sentence += verbs[floor(random(verbs.length))] + " ";
sentence += adverbs[floor(random(adverbs.length))] + ".";
text(sentence, 100, 300);
}
function draw() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.