Scratch Magic 8 Ball Tutorial
Creating a “Magic 8 ball game using Scratch
In this introduction to programming using Scratch, you will learn how to create a “Magic 8-Ball” game. The game will work by asking the user to input a yes / no style question and will respond with one of it’s classic predictions such as: “Yes”, “Most likely” and “Outlook not so good”.
In this introduction to programming using Scratch, you will learn how to create a “Magic 8-Ball” game. The game will work by asking the user to input a yes / no style question and will respond with one of it’s classic predictions such as: “Yes”, “Most likely” and “Outlook not so good”.
Introduction:
The Magic 8-ball is a fortune telling toy created by Mattel in the 1950s.
The Magic 8-ball is a fortune telling toy created by Mattel in the 1950s.
Image by CRASH:Candy, used under a Creative Commons Attribution 2.0 Generic license (Flickr image link)
The concept is simple. Ask the 8-ball a yes or no question and the 8-ball will reply with answers such as “Yes”, “No”, “Without a doubt” etc. (Seemingly being able to predict the future)
The Magic 8 Ball is made up of 20 responses – 10 positive, 5 negative and 5 neutral. The 20 answers are:
Positive answers:
● It is certain ● It is decidedly so ● Without a doubt ● Yes definitely ● You may rely on it ● As I see it, yes ● Most likely ● Outlook good ● Yes ● Signs point to yes
Negative answers:
● Don't count on it ● My reply is no ● My sources say no ● Outlook not so good ● Very doubtful
Neutral answers:
● Reply hazy try again ● Ask again later ● Better not tell you now ● Cannot predict now ● Concentrate and ask again
The Magic 8 Ball is made up of 20 responses – 10 positive, 5 negative and 5 neutral. The 20 answers are:
Positive answers:
● It is certain ● It is decidedly so ● Without a doubt ● Yes definitely ● You may rely on it ● As I see it, yes ● Most likely ● Outlook good ● Yes ● Signs point to yes
Negative answers:
● Don't count on it ● My reply is no ● My sources say no ● Outlook not so good ● Very doubtful
Neutral answers:
● Reply hazy try again ● Ask again later ● Better not tell you now ● Cannot predict now ● Concentrate and ask again
In this tutorial, you will learn how to create a “Magic 8-Ball” game. The game will work by asking the user to input a yes / no style question and will respond with one of it’s classic predictions such as: “Yes”, “Most likely” and “Outlook not so good”.
Starter:
Try on of the Magic 8-Ball simulators. When playing the game, think about how the game might work.
Note: Use these sites at your own risk. TeachwithICT.com is not responsible for the content of external Internet sites.
Online Magic 8-Ball games:
Ask the Magic 8 Ball – http://eightball.tridelphia.net
The Magic 8-Ball - http://lord.xopl.com/ulpage3a/8-ball.html
STEP 1: Introducing the 'Pick Random' operation
Before creating your very own Magic 8-ball game, let's explore the 'Pick random' operation in Scratch.
Look at the sample code (below). Can you guess what the code is doing. Click play button to see if you were right:
Starter:
Try on of the Magic 8-Ball simulators. When playing the game, think about how the game might work.
Note: Use these sites at your own risk. TeachwithICT.com is not responsible for the content of external Internet sites.
Online Magic 8-Ball games:
Ask the Magic 8 Ball – http://eightball.tridelphia.net
The Magic 8-Ball - http://lord.xopl.com/ulpage3a/8-ball.html
STEP 1: Introducing the 'Pick Random' operation
Before creating your very own Magic 8-ball game, let's explore the 'Pick random' operation in Scratch.
Look at the sample code (below). Can you guess what the code is doing. Click play button to see if you were right:
Click here to see inside the code.
Source code: https://scratch.mit.edu/projects/603671205
Challenge 1
Using the sample 'Dice roll' solution above, create a new program to simulate the roll of a dice.
Hint: You can use this partially working example to help you with this task.
Example:
Source code: https://scratch.mit.edu/projects/603671205
Challenge 1
Using the sample 'Dice roll' solution above, create a new program to simulate the roll of a dice.
Hint: You can use this partially working example to help you with this task.
Example:
Source code: https://scratch.mit.edu/projects/608189165
STEP 2 – Creating a simple Magic 8-Ball game
Using what you have learnt, create a 'Magic 8-Ball' game that will randomly pick from the following replies:
Yes
No
Maybe
Hint: You can use this partially working example to help you with this task:
https://scratch.mit.edu/projects/625783212
Your finished program should look like this:
Using what you have learnt, create a 'Magic 8-Ball' game that will randomly pick from the following replies:
Yes
No
Maybe
Hint: You can use this partially working example to help you with this task:
https://scratch.mit.edu/projects/625783212
Your finished program should look like this:
STEP 3 – Advanced Magic 8-Ball game (Adding all 21 responses)
We could use if statements for all 21 game responses but this is not very efficient. There is, however, a better way using a list.
Challenge
Use the following partially working example to help you with this task:
scratch.mit.edu/projects/625790855
Your finished program should look like this:
We could use if statements for all 21 game responses but this is not very efficient. There is, however, a better way using a list.
Challenge
- Input all of the 20 classic answers. (See above)
Hint: You can change the answers if you wish however, you must keep to the format of 10 positive, 5 negative and 5 neutral answers.
Use the following partially working example to help you with this task:
scratch.mit.edu/projects/625790855
Your finished program should look like this:
Taking it further:
Challenge
Challenge
- Comment your code to explain how it works.
- Modify your code so that the pause is random.
- Modify your code so that the game repeats (loops) until the player tells it to stop.
Scratch 'Magic 8-Ball' lesson is licenced under a Creative Commons Attribution 4.0 International License.
Tags: coding on computer, computer coding, best place to learn coding online, online coding, online code, computer programming and Coding, hour of code program, computer science degree programs, programs for computer science, what does coding mean in computers, how does computer code work, what is computer programmer, programming language python, python programming language, Scratch coding language, programming languages Scratch, Scratch code language, Scratch programming language example, what is the Scratch programming language, Scratch scripting, Scratch language tutorial, what type of programming language is Scratch, Scratch class, Scratch how to learn, learn Scratch, learn Scratch from scratch, where to learn Scratch, coding on computer, computer coding, best place to learn coding online, online coding, online code, computer programming and Coding, hour of code program, computer science degree programs, programs for computer science, what does coding mean in computers, how does computer code work, what is computer programmer.