Skip to content

Instantly share code, notes, and snippets.

@nataliefreed
Created February 23, 2017 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nataliefreed/738279b68c30faf21ee45e84d2d55936 to your computer and use it in GitHub Desktop.
Save nataliefreed/738279b68c30faf21ee45e84d2d55936 to your computer and use it in GitHub Desktop.
/*
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