Blocks in Scratch from scratch – training for children 8-9 years old and older

What is Scratch? It is a visual programming environment designed for children and teenagers. Programming here is carried out by moving visual program blocks, small “bricks” are combined into “branches”. It's simple: just take the block from the script menu and move it to the programming field, and we will see the result on the stage on the right.

In Scratch, blocks are divided into sections: movement commands, sensors, conditions, etc. In this material, a programming school for children Pixel will tell you what types of structures exist in Scratch.

Let's create an easy, exciting game, and in the process we will use Scratch blocks, with which we will begin to get acquainted with this environment.

The blocks are on the left side of the screen and are divided by color

The blocks are on the left side of the screen and are divided by color

Creating your first game in Scratch

Our game will be to catch watermelons. A cat named Scratch, the main character of the environment, will run around the stage and collect pieces. But he will have to be careful and not eat the slice that has already been bitten off.

All Scratch programs start with blocks from the Events palette. Our game (cat program) will be no exception. As we have already noted, the palettes are located on the left; they help to correctly structure our blocks by type.

  1. The program will be launched when the flag is clicked; to do this, place the “When the flag is clicked” block on the field. Then we use a block from the “Variables” palette. In the “Create Variable” window, enter the name “Watermelon”. It will count the caught watermelons. We attach the “Set “my variable” value to 0” block to the previous block and change “my variable” to the newly created “Watermelon”. This block will set the initial value in our calculation.

Creating a Variable in Scratch

Creating a Variable in Scratch

  1. Next, take a block from the Controls palette called “Repeat Always.” It will endlessly repeat the program located inside this block.

  1. From the blue “Movement” palette, take out the “Move to Random Position” block and change the position to “Mouse Pointer”. So we will set the movement of our cat using the mouse.

  1. From the “Control” palette, remove the “If, then” block. It will check the condition.

  1. If there are 10 caught watermelons, then we win. We will create this condition using a block from the Operators palette. We'll need an equality block. Let’s add it to the dark diamond of the “If, then” block. From the “Variables” palette, take out the “Watermelon” block and insert it into the left operator window, then change the value 50 to 10 on the right.

  1. From the “Appearance” palette, take out the “Say “hello” for two seconds” block, with the help of which the cat will be able to report victory. Let's change the text to the appropriate one.

After winning, the game will start over again. To do this, let’s reset our “Watermelon” variable using the already familiar “Set value” block.

Next, from the “Events” palette we will take out the “Send a message” block, with its help we can move on to the next program for the new sprite.

Adding a new watermelon sprite

We will add the next sprite by clicking on the image icon in the lower right corner. We will be taken to the sprite library and here we will be presented with a huge variety of models, we need to find a watermelon.

Now we need to get a piece out of a whole watermelon, for this we will change its costume. This can be done in the “Costume” tab, located in the upper left corner of the screen.

A whole slice of watermelon will also have its own program.

  1. It will start with the recognizable block “When the flag is clicked.”

Then we’ll add the “Repeat always” block.

  1. It will endlessly repeat two blocks from the same Controls palette. “Wait one second,” where we will change the number one to two, and “Create a clone of yourself,” which will allow you to catch the constantly appearing many watermelon slices.

Separately, we will create a program that specifies the random movement of watermelon slices around the stage.

  • From the “Control” palette, take out the “When I start as a clone” block and attach to it the block from the “Movement” palette – “Swim for one second to a random position.” Let's change the number one to two.

  • The next program on this sprite starts again with the “When I start as a clone” block. Next is the “Repeat always” block. We will add to them the conditional block “If then”. To the condition, add a block from the “Sensors” palette – “Mouse pointer touches”, change the mouse pointer to sprite 1. This block checks the touch of our watermelon slice and the cat.

If the cat touches the watermelon, the slice will disappear from the screen. To do this, remove the “Hide” block from the “Appearance” palette and change the value of the “Watermelon” variable to one.

And finally, after moving from the cat program, that is, using the “When I receive a message” block, add a block from the “Control” palette – “Delete clone”.

Additional condition for the game

But the game will not be so simple. Let's add a bitten slice, when caught, our accumulated watermelon points will decrease. We will do this similarly to the previous slice, we will only change the design of the slice itself using drawing tools.

The programs for the bitten off piece will be identical to the programs for the whole, so it is enough to transfer them from one sprite to another.

The only difference will be that when you lift a bad slice, the watermelon variable will not increase, but decrease, so let’s change the value to -1.

That's all, let's try to launch and play our game. Click on the green flag and try to catch only 10 of the best slices.

This is how quickly and easily it turned out to create a simple game in Scratch, using various blocks from the palette.

Video: Introducing blocks in Scratch and creating your first game

***

And if you want to learn more about programming in Scratch, come to courses to the Pixel online school. We teach children to create games and animation from scratch, and introduce them to block programming.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *