Education

Workshop Create your own game with Scratch 3.0

robokidz
robokidz
7 min read

Programming difficult? Not with Scratch. This allows you to quickly and easily assemble your own computer programs. We help you on your way with this workshop.

To make a computer program you need a programming language. Most are quite tricky to learn, but Scratch is an exception. You don't have to type complicated English commands in Scratch. To get to know the latest version of Scratch, make a simple game step by step in this workshop. This game is based on one of the very first computer games: Pong.

Welcome to Scratch

To program with Scratch 3.0, use the scratch coding for kids editor. This editor works in almost all internet browsers except Internet Explorer. Use your browser to go to scratch.mit.edu At the bottom of the website you will find the FAQ under Support . It contains, among other things, solutions for problems with Scratch.

Starting a new program in Scratch is simple. Click the Create option at the top left . You enter the editor. Usually there is a green video window here explaining what Scratch is. You close it with a click on the cross. Is Scratch not in Dutch yet? Then click on the globe and Dutch .

The Scratch editor consists of several parts. The list on the left is called the Block Palette . Here, all Scratch commands are divided into different groups, such as Motion and Control . At the top right is the Playfield , where you can see the results of your program. At the bottom right is the Sprite box . Sprites are animated graphics commonly used in games. Scratch always starts with a sprite of the cat. The box in the middle is called the Script Zone . Here you create your program using the command blocks.

The outside first
Before you really start programming, you make the outside of your game. You choose the sprites and the background. You don't need the cat's sprite, so remove it from the sprite box at the bottom right. At Sprite1, click the trash can icon.

You now choose a new sprite. Click on the blue circle with the white cat. You will now see an overview with all sprites. In our version of the game we are trying to chase a bat away, so click on Bat . The bat has been added to the Sprite space and also the Playfield . You make the bat a bit smaller by replacing 100 with 50 at Size . Click on an empty spot in the Sprite box .

You add a second sprite that you use to chase the bat in the game. Go to the sprites via the blue circle with the white cat. In the Search box at the top left, type paddle . This is a kind of racket in the shape of a stripe. Click on it to put this sprite in your game as well.

Finally, add a background to your game. Click the blue button at the bottom right of the Playfield box . Here are all the backgrounds. Search for woods and click on it.

The look of your game is ready. You will soon change the places where your sprites are located with your program.

Creating a program
To create a program in Scratch, drag commands one by one from the Blocks palette to the Script zone next to it. Programming largely involves putting the right commands in the right order. That way the program does what you want.

In a game with multiple sprites you usually make a piece of program per sprite. In our game you start with the paddle. Just click the Spritevak on Paddle .

In the first part of a program, you set the initial values correctly. For example in this game you set the counter that keeps the score to 0 and the number of lives to 10. You also put the paddle in the right place in the Playfield . This way you can be sure that you always start a new game with a clean slate.

The first commands
You usually start a program with an Event command. Click on the yellow Event button on the left side of the editor. This type of command springs into action when something happens. For example, when you click on the green flag in the Scratch editor. This will start the game. Drag the When (green flag) is clicked command at the top of the Script area .

With your second command you put the paddle in the right place. To do this, use a command block from the Movement group . Click the blue Motion button . Drag Go to x: (number) y: (number) at the bottom against the first command in the Script zone . You'll see a shadow below the parent command if you're okay with your new command block. Then let go.

Scratch's command blocks fit together like puzzle pieces. If a piece doesn't fit, you know that you can't put those two commands together. Therefore, make sure that the correct command blocks are attached to each other, otherwise they will not be executed as a program (part).

Get more - robotics classes in pune  

Changing
properties You can change the properties of certain commands. Some have white boxes with a number or text. Others have a list of options. Click in the Go to x: (number) y: (number) command in the box behind x and type: 0 . Replace the number after y: with -140 . This puts the paddle on the 0,-140 spot in the Playfield . The position 0.0 is exactly in the middle of the Playfield .

It's a good idea to try out your program piece by piece as you build. This way you immediately remove the errors. This is called debugging . Click on the button with the green flag at the top left of the Playfield . The paddle is placed in the right place at the bottom center.

Counting with variables


A variable can contain different contents. For example, consider the score in a game that changes. In a program, you usually specify the variables at the beginning. To do this, click on the orange group Variables . Click Create a variable . As the variable name, type Score and click OK . In the same way create the variable Lives . The variables are automatically placed in the Playfield , so that you can see content.

To always start the score in the game at 0, add the Make (Lives) 0 command to the program. You change the variable Lives into Score by clicking on the arrow and then Score . Add another Create (Lives) 0 block . Change the 0 to 10. This keeps track of the number of lives.

Discussion (0 comments)

0 comments

No comments yet. Be the first!