Lesson 4.2: Magic 8-Ball Fortune Teller
Welcome, mystics and programmers! Today, you’re going to create a program that can tell the future. We’ll build our very own digital Magic 8-Ball that gives a mysterious, random answer every time you ask it a question.
What You’ll Learn
By the end of this magical lesson, you’ll be able to:
- Program your sprites to give random responses when you tap them.
- Understand how computers can pretend to make random choices.
- Build a complete, interactive program from a plan to a final product.
- Find and fix bugs when your program doesn’t work the way you expect.
Your Magical Creation Plan
The Mystery of Randomness (10 minutes)
- Let’s look at a real Magic 8-Ball. How does it give a different answer every time? It’s a mystery!
- Let’s brainstorm other things that are random. (Rolling dice, flipping a coin, rock-paper-scissors).
- Today’s challenge is announced: Can you program your own fortune teller?
Designing Your Fortune Teller (15 minutes)
- First, be an artist! On paper, sketch out what your fortune teller will look like. Will it be a classic 8-ball, a crystal ball, or something totally new?
- Next, be a writer! Come up with 6-8 different fortunes your program can give. Make them a mix of “yes,” “no,” and “maybe” answers.
- Finally, be a designer! Plan how the user will interact with it. (Hint: They’ll tap it to get a fortune!)
Programming the Magic (20 minutes)
- Now, let’s build it in Scratch Jr.!
- We’ll learn a new trick using “broadcast” messages (the orange blocks) to help us create a random response.
- Your teacher will show you the basic steps, and you can add your own creative flair with cool sounds and visual effects.
Testing and Debugging (5 minutes)
- Time to test your creation! Does it give a different answer each time?
- Let a partner test your program and give you feedback.
- If you find any bugs, now is the time to be a detective and fix them.
- Let’s celebrate all the working fortune tellers!
Your Mystic’s Toolkit
- A real Magic 8-Ball to examine (if we have one!)
- Design worksheets for planning your creation
- Your device with Scratch Jr.
- A list of example fortunes to get you started
- A simple “bug-squashing” checklist to help you test
How to Become a Master Mystic
- We’ll look at your awesome design plans.
- The Random Test: Does your final program successfully give random answers when you tap it?
- Your creativity in making the project your own is a huge part of the magic!
New Tech Words to Master
- Random: Unpredictable; without a pattern. Computers are great at pretending to be random!
- Broadcast: A special message that one sprite can send to another to trigger an action.
- User Input: The action the user takes to interact with the program, like tapping the screen.