Make Your Own Quiz Game

Let’s create a Make-Your-Own-Quiz Game in Scratch!

If this is your first time using Scratch, make a (free!) account on their website to get started — click here!

I will be using the online version — If you have an older Raspberry Pi, you may have an older version of Scratch. We should still be able to do all the same things, but my categories might look a little different from yours.

Setting up our Game
We are going to want to put in Sprites and backgrounds to start. Let’s add in our Sprites first by going to New Sprite: Choose sprite from library. I chose Avery, and decided to delete the original Scratch sprite (right click and hit ‘delete’).

Next I’m going to click on “stage.” Next to the “Scripts” tab, click on the “Backdrops” tab. I’m going to “choose backdrop from library,” and choose the “chalkboard” backdrop since this is going to be a Quiz. Your Scratch game should look like the following:
Screen Shot 2017-07-19 at 12.01.30 PM

Programming the beginning of our Quiz Game
Let’s first have our Sprite introduce themselves. Click on the Avery sprite at the bottom, and begin by dragging and drop ‘when the green flag is clicked‘ over to scripts (located under Events). This is going to tell the program when to run our script(s).

Under our starting event we just added, I want my Sprite to introduce herself. I’m going to do this by going to Looks, and dragging over say ‘Hello!’ for ‘2’ secs, but changing Hello! to “Hello! My name is Avery.”

Now I want to ask the person playing the game what their name is, and store whatever they input as a variable that I can call back on later. Add this is by going to Sensing and dragging over ask ‘What’s your name?’ and wait. I want my Sprite to then say “Welcome to my game” with the name that was entered, so I drag over another say ‘Hello!’ for ‘2’ secs and replace the Hello! with a join ‘hello’ ‘world’ under Operators. I’m going to replace ‘hello’ with ‘Welcome to my Quiz Game, ” and replace ‘world’ with answer (located under Sensing). The last thing I want to do before my Sprite starts asking questions is tell the user that we are about to begin. I’ll do this by dragging over one more say ‘Hello!’ for ‘2’ secs, and replacing ‘Hello!’ with ‘Let’s begin!’. Once done, your script should look like the below.
Screen Shot 2017-07-19 at 12.21.45 PM

Adding in the actual quiz
We are now ready to add in our actual questions. These can be anything you want, but they have to be something with a right or wrong answer. Let’s start by adding onto our beginning script with our very first question. We are going to do this the same way as when we asked the user what their name is — ask and wait — but this time, I’m going to fill it in with my question ‘What does USB stand for?’ Next we will add our if/then/else from Control. IF the answer is correct, THEN it will execute some code, ELSE (if they get it wrong) it will execute some other code. Go to Operators and grab the ‘ ‘ = ‘ ‘ box and drag it into the if/then/else. In the first blank box, we are going to drag our answer and in the second box we are going to put the correct answer — ‘Universal Serial Bus’.

Let’s fill in what happens when they get it right first. I’m going to drag over say ‘Hello!’ for ‘2’ secs and replace the text with ‘Correct! You move onto the next round!’ under IF. Under ELSE I’m going to drag over say ‘Hello!’ for ‘2’ secs and replace it with That is incorrect. You lose.’

Our first question is done! BUT, I only want to ask the second question IF they get the first one right, so inside the first part of my IF, I’m going to ask and wait again, with my question being ‘What does RAM stand for?’. We are going to do this the same way as the first question now, with our if/then/else statement. IF the answer = ‘Random Access Memory’, then say ‘Correct again!’ for ‘2’ secs, ELSE say ‘Incorrect! You lose.’ for ‘2’ secs. Your code should look like the below.
Screen Shot 2017-07-19 at 12.41.42 PM

We can then keep adding on questions in this same way — You could make your game as long as you want!

Adding in Score
It wouldn’t be a game if we couldn’t keep score! To add this in, make a variable under Data. We are going to name it “score”. We will want to start our game with a score of zero, so right after the starting event I’m going to add set score to 0.

Every time they get a question right, I want them to get a point. To do this, I’m going to add change score by 1 in the code that runs IF they get it right. You will repeat this for every question that you ask.

You final code should look like the below.
Screen Shot 2017-07-19 at 12.58.40 PM

Challenge: How would you add a ‘Game Over’ screen? What else could you add to make this game better?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s