Number Guessing Game Project with Scratch

09-07-2018 13:30
Number Guessing Game Project with Scratch
Number Guessing Game Project with Scratch

In our Number Guessing Game project, we will work with Anna as the character. Anna will pick a random number between 1 and 10 and ask us to guess the number she is holding.
Number Prediction with Scratch
Let's go to https://scratch.mit.edu to create our project. Click on Create from the menu at the top. If you are using the Scratch site in English, you need to click on the Create field.
When we create our new project, we will see the Scratch cat on an empty stage.
 
Stage Layout
Right click on the cat in the Puppets section. Let's remove our cat from the scene with the delete option.
Now, to add a new puppet to our scene, let's click on Select puppet from library, which is among the New puppet options in the puppets section.

Let's choose the character Anna from the puppet library. Of course you can choose any other character you like.
 

Now, let's click on select the decor from the library in the new decor area in the scene section.
 

Let's choose the bench with view decor from the decor library that opens before us.


Now, let's choose the puppet named Magic Carpet from the puppet library and add it to the scene to make our scene look better.

Now we can edit our scene. I set Anna to stand on the flying carpet. You can arrange your scene with the decors of your choice.
Now that we have prepared our scene, we can move on to the coding phase.

Coding
Anna character will keep the numbers in the number guessing game. Let's choose the character Anna from the puppets. [AnnaKodlar.png]
Let's start coding our game by selecting our blocks from the code blocks field called Arrays.

First we need to create a variable to hold a number in memory. Let's go to the Data group under Arrays and click the Create a Variable button.
In the new window that opens before us, let's specify the number kept as the variable name. We will only use this variable with the Anna character. Not for all puppets, let's select Only for this puppet and click the OK button to create our variable.
After the variable is defined, the value of the variable will appear at the top left of the scene.
 
The retained number must not be seen by the player. Because the aim of the game is to guess this number. We do not want to delete this variable. We just want him not to appear on stage. For this, let's find our Number variable kept in Data blocks and empty the box by clicking the box on the left.
Our variable is no longer visible on the stage, but it is still inside our project and running. Now let's make sure that our Anna character is selected and let's make our game by connecting our code blocks as follows.

Fun time
Click the green flag to start the game. When Anna asks, enter your guess in the field at the bottom of the stage. You can have fun together by playing with your friends and family.

Duty
Your task is to develop the project a little further. We want to hear the sound of applause when the correct guess is made, and the sound of the error when the wrong guess is made. Some plugins for this project
needs to be done. Improve the project and don't forget to share it so other people can benefit as well. See you in another project...
 
This article is taken from the 6th issue of Çırak Magazine.
We recommend that you review the following book so that your children can practice more with Scratch.

IdeaSoft® | E-Ticaret paketleri ile hazırlanmıştır.