Create a short, 3-4 sentence story using arrays, methods and text!
Your story can take a few different forms, but it needs to generate new random variations every time it runs. Here are some examples:
- One Sentence Story
- "The [adjective] [noun] [verbed] the [thing]. Everyone was very [emotional state] about it."
- "The lazy student ate the nuclear launch codes. Everyone was very ambivalent about it."
- "The bashful pirate danced with the chipotle burrito. Everyone was very distressed about it."
- D&D Character Generator:
- "I'm going to play a [adjective] [race] [class] from [location] who [personal trait]."
- "I'm going to play a unscrupulous dwarf wizard from the Underdark who has an irrational fear of cats."
- "I'm going to play a hungry hungry orc alpaca farmer from the base of a Volcano who struggles with proper grammar."
- Hacker Actor Generator
Divide your program into methods and print a simple two-element story to the console
- At this stage you should have two elements in your story that change. Each should have two possibilities.
- Set your screen size to 1000 wide by 200 tall.
- Create a String variable named story. This will hold the words you want to output to the user.
- Write the following methods
void setStory() // combines elements from different methods and stores them in the variable story
void tellStory() // outputs the story to the console
String getAdjective() // returns a random adjective. Feel free to rename this method to fit your needs!
String getNoun() // returns a random noun. Feel free to rename this method to fit your needs!
- Call these methods in
setup()
. You do not need to use draw() yet.
Expand your story telling options but keep it printing to the console
- At this stage you should have at least five elements in your story that change. Each should have at least five possibilities.
- This means you will need to add three new methods, and add options to each of your methods.
Make your program display this information on the console
- Change your code in tellStory() to output text to the canvas instead of to the console.
- Set appropriate fonts, alignments, and background colors.
- You may need to add line breaks at predetermined spots ("\n") to have it all fit on the screen
- When the user clicks on the screen, it should display a new story
- To do this you'll need to use a timer
- Fix your formatting so that it always breaks to the next line based on a set number of characters or text width, rather than at arbitrary points. Your message should look like a solid "block" of text.
- To complete this, you'll need to do some independent research - you'll need more tools to work with Strings!