Fun programming with Processing, episode 56. We had a program that wrote a random adjective and a random noun together. It was printing things like "tall tree" or "sticky sky". We continue changing this program so it can write longer sentences. Until now we had an array with adjectives and another array with nouns. We add three new arrays: articles, verbs and prepositions. This allows us to build rather long sentences.
To print the words we create our own function called write_word(). This function only receives one parameter: an array of words. So if we want to print a random adjective, we use write_word(adj). If we want to print a random preposition, we call write_word(pre).
The function receives the whole list of words. Looks at how many words there are in this list, and prints one of them randomly.
www.funprogramming.org
Link to this comment:
All Comments (0)