Lesson 4.6: Stories in Scratch, Madlibs

Learning Objectives:
  • Students will use variables to create Madlibs in Scratch.

Do Now: 
Watch: 

YouTube Video




Explore: 
Activity: Madlibs!

Let's say you want to create a very simple game that takes in user inputs (asking the player what he/she would want to choose). What's the perfect example -- Madlibs!!! This is a great activity because it is rather quick, fun, and implements variables to gather user inputs. 

For those of you who have not played Madlibs before, the basic overview is you create a story with blanks throughout for players to fill in. These blanks can be adjectives, nouns (people, places, things), verbs, adverbs, numbers. You then ask the players to fill-in-the-blanks without actually reading the story, which leads to silliness and randomness. For example you would say, "give an adjective ended in 'st'" or "give a place". You then read the story with the filled-in-blanks.

Here is our Pizza Madlib example. 

A basic outline of How to Make a Madlibs game on Scratch:

1) Create a story with appropriate blanks.  

2) Set the story/text to the background by selecting "backdrop" and using the text option to type or paste. You should also create a different second backdrop (without text), which is used when collecting answers (because you want the text part to be hidden while players provide all their answers). 

3) Create variables.

The fill-in-the-blanks would be treated as variables, which you can find by going to the orange "data" section and then clicking "make a variable". You would then click the "when flag clicked" block under the "events" section and hide each of the variables (which can be found under the "data" section and clicking "hide ______ variable"). You would also want to make sure the background is set to the one without text, which you can do by clicking the "switch background to _____" under the "looks" section. 

4) Ask questions/Collect User Inputs

Ask the user to give you an answer for a specific noun/verb/adjective/adverb, which you can do by going to the "sensing section" and clicking "asking ____ and wait". You would then set the variable you created to "answer" (which can be found in the "sensing" section), using the "set variable to ___" (which can be found in the "data section"). You would then repeat this for all the variables you created.

5) Switch the backdrop back to the one with text, and reveal all the variables by clicking the "showing variable ___________" under the "data section".

You are now done! 




Lesson 4.6 Wrap Up:
Reflection: Variables 
In this Madlib lesson in Scratch you used variables.
Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.
  •                      
Comments