Make a minigame with Scratch

Welcome to the workshop! You will learn how to create a minigame with Scratch. You can start by following the steps and recreate the example. After that, add your own ideas, graphics and rules to make the game unique. Remember: you are the programmer, so only you decide how the game is going to work!

Do you see the triangle at the left of this sentence? That means you can read more if you want to, but you don't need to. Click on this triangle to learn something about saving your game.

Scratch can automatically save your game if you are logged in, so you don't lose your hard work. To save time, I've created a Scratch account for you that you can use. The username is mch2022 and the password is cybercyber. Please don't change the password or email address. Of course you can also create and use your own account. Click the remix button to save your game for the first time.

Escape the maze!

Open the example project. You should see the this screen, with Giga standing at the start of a maze:

Click on the triangle if you want to learn more about the screen above.

Press the green flag at the top-right of the screen. This will start the game. But... nothing happens. Even when you press the arrow keys on your keyboard. That's because there are no scripts yet. The programmer, that's you, will need to make the game work and help Giga escape the maze.

Make Giga move

To start, we will make Giga move when you press the green flag. Go to the yellow event blocks and drag the when flag clicked block to the middle of the screen, the scripts area:

All scripts in Scratch start with an event block. That's why those blocks have a hat on. They tell when something happens. Now we need to add a block to tell the computer what needs to happen. We want to make Giga move to the right. Add a blue change x by 10 block:

Press the green flag again (and again and again). What happens?

Make Giga move with an arrow key

Of course, it would be better to use the arrow keys on your keyboard to make Giga move, instead of the green flag. Grab the when space key pressed block and add it to the scripts area. Change it to when right arrow key pressed:

Now move the change x by 10 block so it's connected to the when right arrow key pressed block, like this:

Now press the green flag and press the right arrow a few times. What happens?

Now in all directions

That was one arrow key, to go to the right. Can you finish it for all other directions? Left, up and down?

Try it yourself first. Can't get it to work? You can look below for the answer.

Walk the walk

With these scripts, Giga can walk in all directions:

Try it out! Does it work well? Not completely, right? Giga can still walk through the walls of the maze! Let's change the scripts so that isn't possible anymore. We'll make it so that when she hits a wall, she'll go back to the start of the maze.

Hit the wall and you're out

Go to the event blocks and grab a forever block. Put it under a when flag clicked block:

You can put blocks inside the forever block. These blocks will be 'forever' repeated and repeated. A computer is very good at repeating stuff. Put a turn right 15 degrees block inside the forever block:

Now press the green flag. What happens? Giga is getting a bit dizzy. Try to add some more blocks inside the forever blok, and see what happens.

Now, we don't want to make Giga dizzy. We only want to make her go back to the start of the maze when she hits the wall. For this, we need to let the computer decide if Giga is hitting the green wall. We can do this with the if ... then block. Remove everything from the forever block, and put the if ... then block in:

We still need to tell the computer what decision needs to be made. Add a touching color ...? block to the if ... then. Do you see that the angular shape of the touching color ...? block is exactly right for the hole in the if ... then block?

The color in the touching color ...? block isn't correct yet. It needs to be the exact same green as the green in the walls of the maze. First click on the color picker button, and then click on the green color of the maze:

Now we need to tell the computer what needs to happen if Giga hits the green wall of the maze. You can use a glide in ... seconds to X: ... Y: ... block to move her back to the start:

Now play your game and see what happens when Giga hits the wall.

Make your game complete

This is only the start of a game. Now add your own rules and sprites to make the game unique and yours. Here are some ideas, but please come up with your own:

Use your imagination, work together with someone else, proudly show your work, and don't forget to ask for help. Have fun!